mirror of
https://github.com/Redocly/redoc.git
synced 2025-07-03 02:33:04 +03:00
Fix allOf withing array items (fixes #136)
This commit is contained in:
parent
d1862ecea0
commit
efcb811151
|
@ -35,10 +35,11 @@ export class SchemaSample extends BaseComponent implements OnInit {
|
||||||
let base:any = {};
|
let base:any = {};
|
||||||
let sample;
|
let sample;
|
||||||
|
|
||||||
// got pointer not directly to the schema but e.g. to response obj
|
// got pointer not directly to the schema but e.g. to the response obj
|
||||||
if (this.componentSchema.schema) {
|
if (this.componentSchema.schema) {
|
||||||
base = this.componentSchema;
|
base = this.componentSchema;
|
||||||
this.componentSchema = this.componentSchema.schema;
|
this.componentSchema = this.componentSchema.schema;
|
||||||
|
this.pointer += '/schema';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base.examples && base.examples['application/json']) {
|
if (base.examples && base.examples['application/json']) {
|
||||||
|
@ -48,7 +49,7 @@ export class SchemaSample extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
this.componentSchema = this._normalizer.normalize(this.componentSchema, this.pointer);
|
this.componentSchema = this._normalizer.normalize(this.componentSchema, this.pointer);
|
||||||
|
|
||||||
let discriminator = this.componentSchema.discriminator || this.componentSchema['x-extendedDiscriminator'];
|
let discriminator = this.componentSchema.discriminator || this.componentSchema['x-discriminatorBasePointer'];
|
||||||
if (discriminator) {
|
if (discriminator) {
|
||||||
let descendants = this.specMgr.findDerivedDefinitions(this.componentSchema._pointer || this.pointer);
|
let descendants = this.specMgr.findDerivedDefinitions(this.componentSchema._pointer || this.pointer);
|
||||||
if (descendants.length) {
|
if (descendants.length) {
|
||||||
|
|
|
@ -27,8 +27,11 @@ export class SchemaNormalizer {
|
||||||
let hasPtr = !!schema.$ref;
|
let hasPtr = !!schema.$ref;
|
||||||
if (opts.resolved && !hasPtr) this._dereferencer.visit(ptr);
|
if (opts.resolved && !hasPtr) this._dereferencer.visit(ptr);
|
||||||
|
|
||||||
if (schema['x-redoc-normalized']) return schema;
|
if (schema['x-redoc-normalized']) {
|
||||||
let res = SchemaWalker.walk(schema, ptr, (subSchema, ptr) => {
|
if (!schema['x-redoc-normalized']._pointer) schema['x-redoc-normalized']._pointer = ptr;
|
||||||
|
return schema['x-redoc-normalized'];
|
||||||
|
}
|
||||||
|
let res = SchemaWalker.walk(Object.assign({}, schema), ptr, (subSchema, ptr) => {
|
||||||
let resolved = this._dereferencer.dereference(subSchema, ptr);
|
let resolved = this._dereferencer.dereference(subSchema, ptr);
|
||||||
if (resolved.allOf) {
|
if (resolved.allOf) {
|
||||||
resolved._pointer = resolved._pointer || ptr;
|
resolved._pointer = resolved._pointer || ptr;
|
||||||
|
@ -38,7 +41,7 @@ export class SchemaNormalizer {
|
||||||
return resolved;
|
return resolved;
|
||||||
});
|
});
|
||||||
if (opts.resolved && !hasPtr) this._dereferencer.exit(ptr);
|
if (opts.resolved && !hasPtr) this._dereferencer.exit(ptr);
|
||||||
res['x-redoc-normalized'] = true;
|
schema['x-redoc-normalized'] = res;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user