openapi-codegen
openapi-codegen copied to clipboard
Cannot generate Enums from Dictionary Object
The useEnum
option is a great addition! Super happy that got in. Trying it out I ran into an edge case when generating enums from a Dict object. Given the schema:
{
"Test": {
"additionalProperties": {
"properties": {
"test": {
"enum": [
"A",
"B"
],
"type": "string"
}
},
"required": [
"test"
],
"type": "object"
},
"properties": {},
"type": "object"
}
}
With useEnums: false
:
export type Test = {
[key: string]: {
test: 'A' | 'B'
}
}
With useEnums: true
:
export type Test = {
[key: string]: {
test: undefinedTest
}
}
with a regular object
"Test": {
"properties": {
"test": {
"enum": [
"A",
"B"
],
"type": "string"
}
},
"required": [
"test"
],
"type": "object"
}
export enum TestTest {
A = 'A',
B = 'B',
}
export type Test = {
test: TestTest
}
Was also able to duplicate the same behavior when using allOf
which makes me think #157 is related
Hi @ashervb, thanks for reporting it
can you provide me the allOf
schema that you were able to simulate the same behavior?
@alan-oliv Hello! Unfortunately I didn't document the issue at the time and of course now I'm unable to reproduce it :upside_down_face: . Will keep investigating though.