File tree 1 file changed +6
-5
lines changed
packages/quicktype-core/src/input
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -914,10 +914,9 @@ async function addTypesInSchema(
914
914
915
915
const includeObject = enumArray === undefined && ! isConst && ( typeSet === undefined || typeSet . has ( "object" ) ) ;
916
916
const includeArray = enumArray === undefined && ! isConst && ( typeSet === undefined || typeSet . has ( "array" ) ) ;
917
- const needStringEnum =
918
- includedTypes . has ( "string" ) &&
919
- enumArray !== undefined &&
920
- enumArray . find ( ( x : any ) => typeof x === "string" ) !== undefined ;
917
+ const enumArrayHasString =
918
+ enumArray !== undefined && enumArray . find ( ( x : any ) => typeof x === "string" ) !== undefined ;
919
+ const needStringEnum = includedTypes . has ( "string" ) && ( enumArrayHasString || isConst ) ;
921
920
const needUnion =
922
921
typeSet !== undefined ||
923
922
schema . properties !== undefined ||
@@ -952,7 +951,9 @@ async function addTypesInSchema(
952
951
combineProducedAttributes ( ( { forString } ) => forString )
953
952
) ;
954
953
955
- if ( needStringEnum || isConst ) {
954
+ if ( needStringEnum ) {
955
+ // FIXME: Currently isConst only works for string values because the name generation only works with strings
956
+ // to fix this issue the cases below have to support all types.
956
957
const cases = isConst
957
958
? [ schema . const ]
958
959
: ( ( enumArray as any [ ] ) . filter ( x => typeof x === "string" ) as string [ ] ) ;
You can’t perform that action at this time.
0 commit comments