mirror of
https://github.com/Redocly/redoc.git
synced 2025-03-03 17:35:46 +03:00
fix: correct pointer for the schema
This commit is contained in:
parent
57129d3f58
commit
4ae1574c6c
|
@ -94,9 +94,9 @@ export class OpenAPIParser {
|
||||||
let res;
|
let res;
|
||||||
if (this.spec === undefined) return;
|
if (this.spec === undefined) return;
|
||||||
if (ref.charAt(0) !== '#') ref = '#' + ref;
|
if (ref.charAt(0) !== '#') ref = '#' + ref;
|
||||||
ref = decodeURI(ref);
|
ref = decodeURIComponent(ref);
|
||||||
try {
|
try {
|
||||||
res = JsonPointer.get(this.spec, decodeURIComponent(ref));
|
res = JsonPointer.get(this.spec, ref);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,9 @@ export class OpenAPIParser {
|
||||||
* checks if the objectt is OpenAPI reference (containts $ref property)
|
* checks if the objectt is OpenAPI reference (containts $ref property)
|
||||||
*/
|
*/
|
||||||
isRef(obj: any): obj is OpenAPIRef {
|
isRef(obj: any): obj is OpenAPIRef {
|
||||||
|
if (!obj) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return obj.$ref !== undefined && obj.$ref !== null;
|
return obj.$ref !== undefined && obj.$ref !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ export class FieldModel {
|
||||||
this.name = info.name;
|
this.name = info.name;
|
||||||
this.in = info.in;
|
this.in = info.in;
|
||||||
this.required = !!info.required;
|
this.required = !!info.required;
|
||||||
this.schema = new SchemaModel(parser, info.schema || {}, pointer + '/schema', options);
|
const schemaPointer = (parser.isRef(infoOrRef) ? infoOrRef.$ref : pointer) + '/schema';
|
||||||
|
this.schema = new SchemaModel(parser, info.schema || {}, schemaPointer, options);
|
||||||
this.description =
|
this.description =
|
||||||
info.description === undefined ? this.schema.description || '' : info.description;
|
info.description === undefined ? this.schema.description || '' : info.description;
|
||||||
const example = info.example || this.schema.example;
|
const example = info.example || this.schema.example;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user