Skip to content

Commit

Permalink
#326 improve paths, andcomponents $ref resolution for multi-file specs
Browse files Browse the repository at this point in the history
  • Loading branch information
carmine.dimacsio committed Jul 14, 2020
1 parent c6b3117 commit b114070
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/middlewares/openapi.request.validator.ts
Expand Up @@ -109,6 +109,8 @@ export class RequestValidator {
(<SchemaObject>body).required && !isBodyBinary ? ['body'] : [];
// $schema: "http://json-schema.org/draft-04/schema#",
const schema = {
paths: this.apiDoc.paths,
components: this.apiDoc.components,
required: ['query', 'headers', 'params'].concat(required),
properties,
};
Expand Down
3 changes: 2 additions & 1 deletion src/middlewares/openapi.response.validator.ts
Expand Up @@ -270,7 +270,8 @@ export class ResponseValidator {
for (const [code, contentTypeSchemas] of Object.entries(responseSchemas)) {
for (const contentType of Object.keys(contentTypeSchemas)) {
const schema = contentTypeSchemas[contentType];
schema.paths = this.spec.paths; // add paths for resolution via file types
schema.paths = this.spec.paths; // add paths for resolution with multi-file
schema.components = this.spec.components; // add components for resolution w/ multi-file
validators[code] = {
...validators[code],
[contentType]: this.ajv.compile(<object>schema),
Expand Down

0 comments on commit b114070

Please sign in to comment.