Closed kubernegit closed 2 weeks ago
kcl doc gen --format openapi
to get the kcl schema type defined in the KCL project with the kcl.mod
file.GetSchemaTypeMapping
APIs defined in KCL Go, Rust, Python, Java SDKs to get the kcl type. For example in KCL Python SDK: https://github.com/kcl-lang/lib/pull/95
Then you can use the kcl type to generate any type in any language.
@Peefy Thank you! :)
I want to use kcl as single source of truth to generate some configuration files that can be consumed by other processes. When consuming these json files with python it would be good to have type information of the structure of the data available in python. For that I want to generate a python file that has the same structure as a kcl schema. This way the python linter knows which data to expect and runtime errors can be prevented.
For example this .k-file:
should be converted to this python code:
My question: Is there a kcl-native way to loop through the properties of a schema in order to generate code of the python class?