Consider the following modules structure:
// MyApi.pkl
module my_api.MyApi
import "@OpenapisContrib/SchemaGenerator.pkl"
import "Foo.pkl"
import "Bar.pkl"
typealias Variant = Foo | Bar
variant: Variant
output = SchemaGenerator.generate(this).output
// Foo.pkl
module my_api.Foo
foo: String
// Bar.pkl
module my_api.Bar
bar: Int
Running pkl eval MyApi.pkl produces the following schema:
{
"type": "object",
"title": "my_api.MyApi",
"properties": {
"variant": {
"title": "Variant",
"oneOf": [
{
"type": "object",
"title": "ModuleClass",
"properties": {
"foo": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"foo"
]
},
{
"type": "object",
"title": "ModuleClass",
"properties": {
"bar": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"bar"
]
}
]
}
},
"additionalProperties": false,
"required": [
"variant"
]
}
While the properties structure is correct, the title property of Foo and Bar variants of the Variant typealias are wrong: it is ModuleClass instead of my_api.Foo and my_api.Bar, respectively. The root module's title, my_api.MyApi, is correct.
Consider the following modules structure:
Running
pkl eval MyApi.pklproduces the following schema:{ "type": "object", "title": "my_api.MyApi", "properties": { "variant": { "title": "Variant", "oneOf": [ { "type": "object", "title": "ModuleClass", "properties": { "foo": { "type": "string" } }, "additionalProperties": false, "required": [ "foo" ] }, { "type": "object", "title": "ModuleClass", "properties": { "bar": { "type": "integer" } }, "additionalProperties": false, "required": [ "bar" ] } ] } }, "additionalProperties": false, "required": [ "variant" ] }While the properties structure is correct, the
titleproperty ofFooandBarvariants of theVarianttypealias are wrong: it isModuleClassinstead ofmy_api.Fooandmy_api.Bar, respectively. The root module's title,my_api.MyApi, is correct.