Skip to main content
版本: 0.4.5

OpenAPI to KCL

命令

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

示例:

  • 输入文件:test_open_api_spec.yaml:

    definitions:
    v1.TestInt:
    type: object
    properties:
    name:
    type: string
    format: int-or-string
    required:
    - name
    x-kcl-type:
    import:
    package: v1.test_int
    alias: test_int
    type: TestInt
    swagger: "2.0"
    info:
    title: KCL
    version: v0.0.2
    paths: {}
  • 命令:

    kcl-openapi generate model -f test_open_api_spec.yaml -t ~/
  • 输出:~/models/v1/test_int.k

    """
    This is the test_int module in v1 package.
    amytestThis file was generated by the KCL auto-gen tool. DO NOT EDIT.
    Editing this file might prove futile when you re-run the KCL auto-gen generate command.
    """

schema TestInt: """v1 test int """

  name: int | str
"""name
"""