Skip to content

Commit

Permalink
fix: throws on multi file spec where multiple responses share the sam…
Browse files Browse the repository at this point in the history
…e file ref (#555)

* fix: #553 fail to resolve same refs for multiple paths

* doc: add comment
  • Loading branch information
cdimascio committed Mar 7, 2021
1 parent 4c1354f commit 22d88da
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/middlewares/parsers/schema.preprocessor.ts
Expand Up @@ -249,7 +249,8 @@ export class SchemaPreprocessor {
const options = opts[kind];
options.path = node.path;

if (nschema) { // This null check should no longer be necessary
if (nschema) {
// This null check should no longer be necessary
this.handleSerDes(pschema, nschema, options);
this.handleReadonly(pschema, nschema, options);
this.processDiscriminator(pschema, nschema, options);
Expand Down Expand Up @@ -346,7 +347,11 @@ export class SchemaPreprocessor {
schema: SchemaObject,
state: TraversalState,
) {
if (schema.type === 'string' && !!schema.format && this.serDesMap[schema.format]) {
if (
schema.type === 'string' &&
!!schema.format &&
this.serDesMap[schema.format]
) {
(<any>schema).type = ['object', 'string'];
schema['x-eov-serdes'] = this.serDesMap[schema.format];
}
Expand Down Expand Up @@ -412,6 +417,13 @@ export class SchemaPreprocessor {
const schemas: Root<SchemaObject>[] = [];
for (const [statusCode, response] of Object.entries(responses)) {
const rschema = this.resolveSchema<OpenAPIV3.ResponseObject>(response);
if (!rschema) {
// issue #553
// TODO the schema failed to resolve.
// This can occur with multi-file specs
// improve resolution, so that rschema resolves (use json ref parser?)
continue;
}
responses[statusCode] = rschema;

if (rschema.content) {
Expand Down

0 comments on commit 22d88da

Please sign in to comment.