diff --git a/src/framework/types.ts b/src/framework/types.ts index 41733a9c..57601da0 100644 --- a/src/framework/types.ts +++ b/src/framework/types.ts @@ -262,19 +262,29 @@ export namespace OpenAPIV3 { | 'string' | 'integer'; export type ArraySchemaObjectType = 'array'; - export type SchemaObject = ArraySchemaObject | NonArraySchemaObject; - export interface ArraySchemaObject extends BaseSchemaObject { - type: ArraySchemaObjectType; + export type SchemaObject = ArraySchemaObject | NonArraySchemaObject | CompositionSchemaObject; + + export interface ArraySchemaObject extends BaseSchemaObject { items: ReferenceObject | SchemaObject; } - export interface NonArraySchemaObject extends BaseSchemaObject { - type: NonArraySchemaObjectType; + export interface NonArraySchemaObject extends BaseSchemaObject { } - interface BaseSchemaObject { + export interface CompositionSchemaObject extends BaseSchemaObject { // JSON schema allowed properties, adjusted for OpenAPI + allOf?: Array; + oneOf?: Array; + anyOf?: Array; + not?: ReferenceObject | SchemaObject; + // OpenAPI-specific properties + discriminator?: DiscriminatorObject; + } + + interface BaseSchemaObject { + // JSON schema allowed properties, adjusted for OpenAPI + type?: T; title?: string; description?: string; format?: string; @@ -298,14 +308,9 @@ export namespace OpenAPIV3 { properties?: { [name: string]: ReferenceObject | SchemaObject; }; - allOf?: Array; - oneOf?: Array; - anyOf?: Array; - not?: ReferenceObject | SchemaObject; // OpenAPI-specific properties nullable?: boolean; - discriminator?: DiscriminatorObject; readOnly?: boolean; writeOnly?: boolean; xml?: XMLObject; diff --git a/src/middlewares/parsers/req.parameter.mutator.ts b/src/middlewares/parsers/req.parameter.mutator.ts index de8bb69f..00ece3cd 100644 --- a/src/middlewares/parsers/req.parameter.mutator.ts +++ b/src/middlewares/parsers/req.parameter.mutator.ts @@ -183,7 +183,7 @@ export class RequestParameterMutator { ): void { // fetch the keys used for this kind of explode const type = schema.type; - const hasXOf = schema.allOf || schema.oneOf || schema.anyOf; + const hasXOf = schema['allOf'] || schema['oneOf'] || schema['anyOf']; const properties = hasXOf ? xOfProperties(schema) : type === 'object' diff --git a/src/middlewares/parsers/schema.preprocessor.ts b/src/middlewares/parsers/schema.preprocessor.ts index 3cd0396c..098cfcac 100644 --- a/src/middlewares/parsers/schema.preprocessor.ts +++ b/src/middlewares/parsers/schema.preprocessor.ts @@ -263,10 +263,10 @@ export class SchemaPreprocessor { private processDiscriminator(parent: Schema, schema: Schema, opts: any = {}) { const o = opts.discriminator; - const schemaObj = schema; + const schemaObj = schema; const xOf = schemaObj.oneOf ? 'oneOf' : schemaObj.anyOf ? 'anyOf' : null; - if (xOf && schemaObj?.discriminator?.propertyName && !o.discriminator) { + if (xOf && schemaObj.discriminator?.propertyName && !o.discriminator) { const options = schemaObj[xOf].flatMap((refObject) => { if (refObject['$ref'] === undefined) { return [];