Skip to main content
版本: 0.5.2

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.
This 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

Attributes
----------
name : int | str, default is Undefined, required
name
"""


name: int | str