anyOf combining literals and objects generates incorrect code
The following schema
"schedule": {
"anyOf": [
{
"const": "manual"
},
{
"$ref": "#/components/schemas/SimpleSchedule"
},
{
"$ref": "#/components/schemas/CronSchedule"
}
],
"title": "Schedule"
},
produces the following:
schedule: (SimpleSchedule | CronSchedule);
@danikenan what is the type you'd expect?
@danikenan we just merged a fix for similar issue in our fork, mind having a look if it fixes your problem too?
@mrlubos Doesnt resolve it. The issue is that the tool resolves { "const": "manual" } to any instead of "manual"
@mrlubos Doesnt resolve it. The issue is that the tool resolves `{
"const": "manual"}
toanyinstead of"manual"`
@kevinand11 I'll try to fix it this weekend
@kevinand11 Please open a pull request with failing test case against our fork. The following spec
"AnyOfConst": {
"anyOf": [
{
"const": "foo"
},
{
"$ref": "#/components/schemas/ModelWithString"
},
{
"$ref": "#/components/schemas/ModelWithArray"
}
]
}
generates the following model
export type AnyOfConst = ("foo" | ModelWithString | ModelWithArray);
so I think this works as expected.
@danikenan this is fixed in @nicolas-chaulet/openapi-typescript-codegen