File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,9 @@ export class CodeGenProcess {
127127 } ) ,
128128 ) ;
129129
130+ //set all discriminators at the top
131+ this . schemaComponentsMap . discriminatorsFirst ( ) ;
132+ // put all enums at the top (before discriminators)
130133 this . schemaComponentsMap . enumsFirst ( ) ;
131134
132135 const componentsToParse : SchemaComponent [ ] =
Original file line number Diff line number Diff line change @@ -77,4 +77,13 @@ export class SchemaComponentsMap {
7777 return 0 ;
7878 } ) ;
7979 }
80+
81+ // Ensure discriminators are at the top of components list
82+ discriminatorsFirst ( ) {
83+ this . _data . sort ( ( a , b ) => {
84+ if ( Object . keys ( a . rawTypeData || { } ) . includes ( "discriminator" ) ) return - 1 ;
85+ if ( Object . keys ( b . rawTypeData || { } ) . includes ( "discriminator" ) ) return 1 ;
86+ return 0 ;
87+ } ) ;
88+ }
8089}
You can’t perform that action at this time.
0 commit comments