mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-10 19:06:34 +03:00
fix: do not process oneOf if inherited from parent with discriminator
This commit is contained in:
parent
27a4af7076
commit
5248415791
|
@ -296,7 +296,7 @@ export class OpenAPIParser {
|
|||
* returns map of definition pointer to definition name
|
||||
* @param $refs array of references to find derived from
|
||||
*/
|
||||
findDerived($refs: string[]): Dict<string[]> {
|
||||
findDerived($refs: string[]): Dict<string[] | string> {
|
||||
const res: Dict<string[]> = {};
|
||||
const schemas = (this.spec.components && this.spec.components.schemas) || {};
|
||||
for (const defName in schemas) {
|
||||
|
|
|
@ -75,6 +75,7 @@ export class SchemaModel {
|
|||
this.pointer = schemaOrRef.$ref || pointer || '';
|
||||
this.rawSchema = parser.deref(schemaOrRef);
|
||||
this.schema = parser.mergeAllOf(this.rawSchema, this.pointer, isChild);
|
||||
|
||||
this.init(parser, isChild);
|
||||
|
||||
parser.exitRef(schemaOrRef);
|
||||
|
@ -125,6 +126,13 @@ export class SchemaModel {
|
|||
if (!isChild && getDiscriminator(schema) !== undefined) {
|
||||
this.initDiscriminator(schema, parser);
|
||||
return;
|
||||
} else if (
|
||||
isChild &&
|
||||
Array.isArray(schema.oneOf) &&
|
||||
schema.oneOf.find(s => s.$ref === this.pointer)
|
||||
) {
|
||||
// we hit allOf of the schema with the parent discriminator
|
||||
delete schema.oneOf;
|
||||
}
|
||||
|
||||
if (schema.oneOf !== undefined) {
|
||||
|
@ -227,7 +235,7 @@ export class SchemaModel {
|
|||
continue;
|
||||
}
|
||||
const name = JsonPointer.baseName(variant.$ref);
|
||||
implicitInversedMapping[variant.$ref] = [name];
|
||||
implicitInversedMapping[variant.$ref] = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,6 +247,7 @@ export class SchemaModel {
|
|||
if (Array.isArray(explicitInversedMapping[$ref])) {
|
||||
explicitInversedMapping[$ref].push(name);
|
||||
} else {
|
||||
// overrides implicit mapping here
|
||||
explicitInversedMapping[$ref] = [name];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user