Skip to content

Commit

Permalink
fix: correct pointer for the schema
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Dec 7, 2017
1 parent 57129d3 commit 4ae1574
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/services/OpenAPIParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ export class OpenAPIParser {
let res;
if (this.spec === undefined) return;
if (ref.charAt(0) !== '#') ref = '#' + ref;
ref = decodeURI(ref);
ref = decodeURIComponent(ref);
try {
res = JsonPointer.get(this.spec, decodeURIComponent(ref));
res = JsonPointer.get(this.spec, ref);
} catch (e) {
// do nothing
}
Expand All @@ -107,6 +107,9 @@ export class OpenAPIParser {
* checks if the objectt is OpenAPI reference (containts $ref property)
*/
isRef(obj: any): obj is OpenAPIRef {
if (!obj) {
return false;
}
return obj.$ref !== undefined && obj.$ref !== null;
}

Expand Down
3 changes: 2 additions & 1 deletion src/services/models/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export class FieldModel {
this.name = info.name;
this.in = info.in;
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 =
info.description === undefined ? this.schema.description || '' : info.description;
const example = info.example || this.schema.example;
Expand Down

0 comments on commit 4ae1574

Please sign in to comment.