@@ -167,14 +167,24 @@ export class SchemaObjectFactory {
167
167
168
168
const schemaCombinators = [ 'oneOf' , 'anyOf' , 'allOf' ] ;
169
169
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
+ }
178
188
}
179
189
return property as ParameterObject ;
180
190
} ) ;
@@ -203,7 +213,8 @@ export class SchemaObjectFactory {
203
213
if ( ! propertiesWithType ) {
204
214
return '' ;
205
215
}
206
- const extensionProperties = Reflect . getMetadata ( DECORATORS . API_EXTENSION , type ) || { } ;
216
+ const extensionProperties =
217
+ Reflect . getMetadata ( DECORATORS . API_EXTENSION , type ) || { } ;
207
218
const typeDefinition : SchemaObject = {
208
219
type : 'object' ,
209
220
properties : mapValues ( keyBy ( propertiesWithType , 'name' ) , ( property ) =>
@@ -273,7 +284,10 @@ export class SchemaObjectFactory {
273
284
: undefined ;
274
285
275
286
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' ,
277
291
enum : _enum
278
292
} ;
279
293
}
@@ -301,15 +315,17 @@ export class SchemaObjectFactory {
301
315
const $ref = getSchemaPath ( enumName ) ;
302
316
303
317
// 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' ;
313
329
314
330
schemas [ enumName ] = {
315
331
type : enumType ,
0 commit comments