mirror of
https://github.com/Redocly/redoc.git
synced 2025-03-03 09:25:47 +03:00
Fix dereferencing
This commit is contained in:
parent
003fba8651
commit
afe9020021
|
@ -34,7 +34,7 @@
|
||||||
title="{{prop._displayTypeHint}}"> {{prop._displayType}} {{prop._displayFormat}}
|
title="{{prop._displayTypeHint}}"> {{prop._displayType}} {{prop._displayFormat}}
|
||||||
<span class="param-range" *ngIf="prop._range"> {{prop._range}} </span>
|
<span class="param-range" *ngIf="prop._range"> {{prop._range}} </span>
|
||||||
</span>
|
</span>
|
||||||
<span *ngIf="prop.required" class="param-required">Required</span>
|
<span *ngIf="prop._required" class="param-required">Required</span>
|
||||||
<div *ngIf="prop.default">Default: {{prop.default | json}}</div>
|
<div *ngIf="prop.default">Default: {{prop.default | json}}</div>
|
||||||
<div *ngIf="prop.enum && !prop.isDiscriminator" class="param-enum">
|
<div *ngIf="prop.enum && !prop.isDiscriminator" class="param-enum">
|
||||||
<span *ngFor="let enumItem of prop.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
|
<span *ngFor="let enumItem of prop.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
|
||||||
|
|
|
@ -55,7 +55,7 @@ export class JsonSchema extends BaseComponent {
|
||||||
enumOrder[enumItem.val] = idx;
|
enumOrder[enumItem.val] = idx;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.schema._derived.sort((a, b) => {
|
this.schema._descendants.sort((a, b) => {
|
||||||
return enumOrder[a.name] > enumOrder[b.name] ? 1 : -1;
|
return enumOrder[a.name] > enumOrder[b.name] ? 1 : -1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -63,17 +63,17 @@ export class JsonSchema extends BaseComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareModel() {
|
prepareModel() {
|
||||||
let schema = this.schema = this.componentSchema;
|
this.schema = this.componentSchema;
|
||||||
if (!schema) {
|
if (!this.schema) {
|
||||||
throw new Error(`Can't load component schema at ${this.pointer}`);
|
throw new Error(`Can't load component schema at ${this.pointer}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
schema = this.normalizer.normalize(schema, this.normPointer);
|
this.schema = this.normalizer.normalize(this.schema, this.normPointer);
|
||||||
this.schema = schema = SchemaHelper.unwrapArray(schema, this.normPointer);
|
this.schema = SchemaHelper.unwrapArray(this.schema, this.normPointer);
|
||||||
SchemaHelper.preprocess(schema, schema, this.normPointer, this.pointer);
|
SchemaHelper.preprocess(this.schema, this.normPointer, this.pointer);
|
||||||
|
|
||||||
if (!schema.isTrivial) {
|
if (!this.schema.isTrivial) {
|
||||||
SchemaHelper.preprocessProperties(schema, this.normPointer, {
|
SchemaHelper.preprocessProperties(this.schema, this.normPointer, {
|
||||||
childFor: this.childFor,
|
childFor: this.childFor,
|
||||||
skipReadOnly: this.isRequestSchema
|
skipReadOnly: this.isRequestSchema
|
||||||
});
|
});
|
||||||
|
|
|
@ -31,7 +31,8 @@ export class ParamsList extends BaseComponent {
|
||||||
paramsList = paramsList.map(paramSchema => {
|
paramsList = paramsList.map(paramSchema => {
|
||||||
let propPointer = paramSchema._pointer;
|
let propPointer = paramSchema._pointer;
|
||||||
if (paramSchema.in === 'body') return paramSchema;
|
if (paramSchema.in === 'body') return paramSchema;
|
||||||
return SchemaHelper.preprocess(paramSchema, paramSchema.name, propPointer, this.pointer);
|
paramSchema._name = paramSchema.name;
|
||||||
|
return SchemaHelper.preprocess(paramSchema,propPointer, this.pointer);
|
||||||
});
|
});
|
||||||
|
|
||||||
let paramsMap = this.orderParams(paramsList);
|
let paramsMap = this.orderParams(paramsList);
|
||||||
|
|
|
@ -135,12 +135,11 @@ const injectors = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export class SchemaHelper {
|
export class SchemaHelper {
|
||||||
static preprocess(schema, name, pointer, hostPointer?) {
|
static preprocess(schema, pointer, hostPointer?) {
|
||||||
//propertySchema = Object.assign({}, propertySchema);
|
//propertySchema = Object.assign({}, propertySchema);
|
||||||
if (schema['x-redoc-schema-precompiled']) {
|
if (schema['x-redoc-schema-precompiled']) {
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
schema._name = name;
|
|
||||||
SchemaHelper.runInjectors(schema, schema, pointer, hostPointer);
|
SchemaHelper.runInjectors(schema, schema, pointer, hostPointer);
|
||||||
schema['x-redoc-schema-precompiled'] = true;
|
schema['x-redoc-schema-precompiled'] = true;
|
||||||
return schema;
|
return schema;
|
||||||
|
@ -163,15 +162,16 @@ export class SchemaHelper {
|
||||||
|
|
||||||
let discriminatorFieldIdx = -1;
|
let discriminatorFieldIdx = -1;
|
||||||
let props = schema.properties && Object.keys(schema.properties).map((propName, idx) => {
|
let props = schema.properties && Object.keys(schema.properties).map((propName, idx) => {
|
||||||
let propertySchema = schema.properties[propName];
|
let propertySchema = Object.assign({}, schema.properties[propName]);
|
||||||
let propPointer = propertySchema._pointer ||
|
let propPointer = propertySchema._pointer ||
|
||||||
JsonPointer.join(pointer, ['properties', propName]);
|
JsonPointer.join(pointer, ['properties', propName]);
|
||||||
propertySchema = SchemaHelper.preprocess(propertySchema, propName, propPointer);
|
propertySchema = SchemaHelper.preprocess(propertySchema, propPointer);
|
||||||
|
propertySchema._name = propName;
|
||||||
// stop endless discriminator recursion
|
// stop endless discriminator recursion
|
||||||
if (propertySchema._pointer === opts.childFor) {
|
if (propertySchema._pointer === opts.childFor) {
|
||||||
propertySchema._pointer = null;
|
propertySchema._pointer = null;
|
||||||
}
|
}
|
||||||
propertySchema.required = !!requiredMap[propName];
|
propertySchema._required = !!requiredMap[propName];
|
||||||
propertySchema.isDiscriminator = (schema.discriminator === propName);
|
propertySchema.isDiscriminator = (schema.discriminator === propName);
|
||||||
if (propertySchema.isDiscriminator) {
|
if (propertySchema.isDiscriminator) {
|
||||||
discriminatorFieldIdx = idx;
|
discriminatorFieldIdx = idx;
|
||||||
|
@ -202,7 +202,9 @@ export class SchemaHelper {
|
||||||
static preprocessAdditionalProperties(schema:any, pointer:string) {
|
static preprocessAdditionalProperties(schema:any, pointer:string) {
|
||||||
var addProps = schema.additionalProperties;
|
var addProps = schema.additionalProperties;
|
||||||
let ptr = addProps._pointer || JsonPointer.join(pointer, ['additionalProperties']);
|
let ptr = addProps._pointer || JsonPointer.join(pointer, ['additionalProperties']);
|
||||||
return SchemaHelper.preprocess(addProps, '<Additional Properties> *', ptr);
|
let res = SchemaHelper.preprocess(addProps, ptr);
|
||||||
|
res._name = '<Additional Properties> *';
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unwrapArray(schema, pointer) {
|
static unwrapArray(schema, pointer) {
|
||||||
|
|
|
@ -46,9 +46,15 @@ class SchemaWalker {
|
||||||
let ptr = JsonPointer.join(pointer, ['properties']);
|
let ptr = JsonPointer.join(pointer, ['properties']);
|
||||||
SchemaWalker.walkEach(obj.properties, ptr, visitor);
|
SchemaWalker.walkEach(obj.properties, ptr, visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.additionalProperties) {
|
if (obj.additionalProperties) {
|
||||||
let ptr = JsonPointer.join(pointer, ['additionalProperties']);
|
let ptr = JsonPointer.join(pointer, ['additionalProperties']);
|
||||||
SchemaWalker.walkEach(obj.additionalProperties, ptr, visitor);
|
if (Array.isArray(obj.additionalProperties)) {
|
||||||
|
SchemaWalker.walkEach(obj.additionalProperties, ptr, visitor);
|
||||||
|
} else {
|
||||||
|
let res = SchemaWalker.walk(obj.additionalProperties, ptr, visitor);
|
||||||
|
if (res) obj.additionalProperties = res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.allOf) {
|
if (obj.allOf) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user