Giter Club home page Giter Club logo

kcl-openapi's Introduction

KCL OpenAPI

GoDoc license Coverage Status FOSSA Status

The work on this project is mainly based on go-swagger, and this project just adds some KCL-specific templates and language features to it. We are grateful and sincerely respectful for the outstanding work in go-swagger. Meanwhile, we are working on making the customized features separated from the basic OpenAPI logic in go-swagger.

Main use cases:

  • Swagger Openapi
    • Translate Swagger OpenAPI spec to KCL code
  • Kubernetes CRD
    • Translate Kubernetes CRD to KCL code

Quick Start

Install

The kcl-openapi tool can be installed in both ways:

1 go install

go install kcl-lang.io/kcl-openapi@latest

2 Curl|sh install (MacOS & Linux)

If you don't have to go, you can install the CLI with this one-liner:

curl -fsSL https://kcl-lang.io/script/install-kcl-openapi.sh | /bin/bash

3 Download from release

# 1. download the released binary from:
# https://github.com/kcl-lang/kcl-openapi/releases

# 2. Unzip the package and add the binary location to PATH
export PATH="<Your directory to store KCLOpenAPI binary>:$PATH"

Features

The tool translates Swagger OpenAPI spec and Kubernetes CRD to KCL models.

Translate Swagger OpenAPI Spec to KCL

The tool now supports OpenAPI 2.0. By parsing the "Definitions" section of the spec, the KCL OpenAPI tool will extract the defined models from it and generate the corresponding KCL representation.

The command is as follows:

kcl-openapi generate model -f ${your_open_api_spec} -t ${the_kcl_files_output_dir}

Note: The Kubernetes KCL models among all versions are pre-generated, you get it by executing kpm add k8s:<version> under your project. For detailed information about kpm usage, please refer to kpm quick start guide. Alternatively, if you may want to generate them yourself, please refer Generate KCL Packages from Kubernetes OpenAPI Specs.

Translate Kubernetes CRD to KCL

The tool can also translate the Kubernetes CRD to KCL models. By parsing the spec.versions[n].schema.openAPIV3Schema (n means the latest version of the spec will be used) section of the CRD, the KCL OpenAPI tool will extract the structural schema and generate the corresponding KCL representation.

The command is as follows:

kcl-openapi generate model --crd -f ${your_CRD.yaml} -t ${the_kcl_files_output_dir} --skip-validation

KCL OpenAPI Spec

The KCL OpenAPI Spec defines a complete specification of how OpenAPI objects are mapped to KCL language elements.

Ask for help

If the tool isn't working as you expect, please reach out to us by filing an issue.

License

Apache License Version 2.0

FOSSA Status

kcl-openapi's People

Contributors

amyxia1994 avatar peefy avatar chai2010 avatar michaelchristopher-ui avatar fossabot avatar ldxdl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.