OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
(adding - p legacyDiscriminatorBehavior=false doesn't really change anything)
Steps to reproduce
run the command above
expected behavior
api response has the field .value with the intended type
const api = new ValueApi()
const values = api.getValues()
if (values[0].valueType === 'Int') {
let intValue number
intValue = values[0].value // <= works without error, and preferably has number type after `if (values[0].valueType === 'Int') `
}
actual behavior
.value field doesn' exist
...
intValue = values[0].value // => Property 'value' does not exist on type 'Value'.
Bug Report Checklist
Description
using openapi v2
discriminator
withallOf
doesn't generate desired model types.https://swagger.io/specification/v2/
openapi-generator version
v5.2.1 (same in the current latest master)
OpenAPI declaration file content or url
Generation Details
(adding
- p legacyDiscriminatorBehavior=false
doesn't really change anything)Steps to reproduce
run the command above
expected behavior
api response has the field
.value
with the intended typeactual behavior
.value
field doesn' existactual output
Related issues/PRs
probably none
Suggest a fix
use something like discriminated union in tyepscript
Proof of concept:
Playground link