@@ -167,14 +167,24 @@ export class SchemaObjectFactory {
167167
168168 const schemaCombinators = [ 'oneOf' , 'anyOf' , 'allOf' ] ;
169169 let keyOfCombinators = '' ;
170- if ( schemaCombinators . some ( ( _key ) => { keyOfCombinators = _key ; return _key in property ; } ) ) {
171- if ( ( ( property as SchemaObjectMetadata ) ?. type === 'array' || ( property as SchemaObjectMetadata ) . isArray ) && keyOfCombinators ) {
172- ( property as SchemaObjectMetadata ) . items = { } ;
173- ( property as SchemaObjectMetadata ) . items [ keyOfCombinators ] = property [ keyOfCombinators ] ;
174- delete property [ keyOfCombinators ] ;
175- } else {
176- delete ( property as SchemaObjectMetadata ) . type ;
177- }
170+ if (
171+ schemaCombinators . some ( ( _key ) => {
172+ keyOfCombinators = _key ;
173+ return _key in property ;
174+ } )
175+ ) {
176+ if (
177+ ( ( property as SchemaObjectMetadata ) ?. type === 'array' ||
178+ ( property as SchemaObjectMetadata ) . isArray ) &&
179+ keyOfCombinators
180+ ) {
181+ ( property as SchemaObjectMetadata ) . items = { } ;
182+ ( property as SchemaObjectMetadata ) . items [ keyOfCombinators ] =
183+ property [ keyOfCombinators ] ;
184+ delete property [ keyOfCombinators ] ;
185+ } else {
186+ delete ( property as SchemaObjectMetadata ) . type ;
187+ }
178188 }
179189 return property as ParameterObject ;
180190 } ) ;
@@ -203,7 +213,8 @@ export class SchemaObjectFactory {
203213 if ( ! propertiesWithType ) {
204214 return '' ;
205215 }
206- const extensionProperties = Reflect . getMetadata ( DECORATORS . API_EXTENSION , type ) || { } ;
216+ const extensionProperties =
217+ Reflect . getMetadata ( DECORATORS . API_EXTENSION , type ) || { } ;
207218 const typeDefinition : SchemaObject = {
208219 type : 'object' ,
209220 properties : mapValues ( keyBy ( propertiesWithType , 'name' ) , ( property ) =>
@@ -273,7 +284,10 @@ export class SchemaObjectFactory {
273284 : undefined ;
274285
275286 schemas [ enumName ] = {
276- type : ( param . isArray ? param . schema ?. [ 'items' ] ?. [ 'type' ] : param . schema ?. [ 'type' ] ) ?? 'string' ,
287+ type :
288+ ( param . isArray
289+ ? param . schema ?. [ 'items' ] ?. [ 'type' ]
290+ : param . schema ?. [ 'type' ] ) ?? 'string' ,
277291 enum : _enum
278292 } ;
279293 }
@@ -301,15 +315,17 @@ export class SchemaObjectFactory {
301315 const $ref = getSchemaPath ( enumName ) ;
302316
303317 // Allow given fields to be part of the referenced enum schema
304- const additionalParams = [ 'description' , 'deprecated' , 'default' ]
305- const additionalFields = additionalParams . reduce ( ( acc , param ) =>
306- ( { ...acc , ...( metadata [ param ] && { [ param ] : metadata [ param ] } ) } ) , { } ) ;
307-
308- const enumType : string = (
309- metadata . isArray
310- ? metadata . items [ 'type' ]
311- : metadata . type
312- ) ?? 'string' ;
318+ const additionalParams = [ 'description' , 'deprecated' , 'default' ] ;
319+ const additionalFields = additionalParams . reduce (
320+ ( acc , param ) => ( {
321+ ...acc ,
322+ ...( metadata [ param ] && { [ param ] : metadata [ param ] } )
323+ } ) ,
324+ { }
325+ ) ;
326+
327+ const enumType : string =
328+ ( metadata . isArray ? metadata . items [ 'type' ] : metadata . type ) ?? 'string' ;
313329
314330 schemas [ enumName ] = {
315331 type : enumType ,
0 commit comments