Skip to main content
Version: 0.4.3

OpenAPI to KCL

Command

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

Example

  • 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: {}
  • Command
kcl-openapi generate model -f test_open_api_spec.yaml -t ~/
  • Output ~/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