Is there an interface for getting schema information directly? #497
-
When you are doing codegen for a language binding, you need to get the schema information of a Pkl schema. I know in pkl-swift it basically just concatenates the schema and the Pkl codegen source code written in Pkl in a Pkl file and let's the evaluator do the codegen, but I don't wanna write codegen code in Pkl. As awesome as Pkl is, this is too much pickling for me. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can get this information from the reflect API, which you can then render into JSON/YAML/whatever else. Alternatively, if you are in Java, you can use BTW: What are you looking to do codegen for? NOTE: there is a bug that prevents you from rendering reflect values in 0.25 that is now fixed in 0.26.0-dev (docs for downloading dev executables here: https://pkl-lang.org/main/latest/pkl-cli/index.html#download) |
Beta Was this translation helpful? Give feedback.
-
An interface like that would be useful for generating structs/classes for easy serialisation and deserialisation using a Pkl schema. |
Beta Was this translation helpful? Give feedback.
You can get this information from the reflect API, which you can then render into JSON/YAML/whatever else.
Alternatively, if you are in Java, you can use
org.pkl.core.Evaluator#evaluateSchema
to get a schema object.BTW: What are you looking to do codegen for?
NOTE: there is a bug that prevents you from rendering reflect values in 0.25 that is now fixed in 0.26.0-dev (docs for downloading dev executables here: https://pkl-lang.org/main/latest/pkl-cli/index.html#download)