mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-07 13:30:33 +03:00
parent
6ea2b7b0e6
commit
aaff311a3e
|
@ -111,7 +111,7 @@ export class SchemaModel {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isChild && schema.discriminator !== undefined) {
|
if (!isChild && getDiscriminator(schema) !== undefined) {
|
||||||
this.initDiscriminator(schema, parser);
|
this.initDiscriminator(schema, parser);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,8 @@ export class SchemaModel {
|
||||||
},
|
},
|
||||||
parser: OpenAPIParser,
|
parser: OpenAPIParser,
|
||||||
) {
|
) {
|
||||||
this.discriminatorProp = schema.discriminator!.propertyName;
|
const discriminator = getDiscriminator(schema)!;
|
||||||
|
this.discriminatorProp = discriminator.propertyName;
|
||||||
const derived = parser.findDerived([...(schema.parentRefs || []), this._$ref]);
|
const derived = parser.findDerived([...(schema.parentRefs || []), this._$ref]);
|
||||||
|
|
||||||
if (schema.oneOf) {
|
if (schema.oneOf) {
|
||||||
|
@ -184,7 +185,7 @@ export class SchemaModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapping = schema.discriminator!.mapping || {};
|
const mapping = discriminator.mapping || {};
|
||||||
for (const name in mapping) {
|
for (const name in mapping) {
|
||||||
derived[mapping[name]] = name;
|
derived[mapping[name]] = name;
|
||||||
}
|
}
|
||||||
|
@ -257,3 +258,7 @@ function buildFields(
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDiscriminator(schema: OpenAPISchema): OpenAPISchema['discriminator'] {
|
||||||
|
return schema.discriminator || schema['x-discriminator'];
|
||||||
|
}
|
||||||
|
|
4
src/types/index.d.ts
vendored
4
src/types/index.d.ts
vendored
|
@ -1,5 +1,3 @@
|
||||||
export * from './open-api';
|
export * from './open-api';
|
||||||
|
|
||||||
export type Diff<T extends string, U extends string> = ({ [P in T]: P } &
|
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||||
{ [P in U]: never } & { [x: string]: never })[T];
|
|
||||||
export type Omit<T, K extends keyof T> = { [P in Diff<keyof T, K>]: T[P] };
|
|
||||||
|
|
2
src/types/open-api.d.ts
vendored
2
src/types/open-api.d.ts
vendored
|
@ -1,4 +1,4 @@
|
||||||
import { Omit } from './';
|
import { Omit } from './index';
|
||||||
|
|
||||||
export interface OpenAPISpec {
|
export interface OpenAPISpec {
|
||||||
openapi: string;
|
openapi: string;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user