Skip to content

Commit

Permalink
fix: skip schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
cdimascio committed Jan 9, 2021
1 parent fa04dec commit 617e9d3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "express-openapi-validator",
"version": "4.11.0-beta.1",
"version": "4.11.0-beta.2",
"description": "Automatically validate API requests and responses with OpenAPI 3 and Express.",
"main": "dist/index.js",
"scripts": {
Expand Down
6 changes: 2 additions & 4 deletions src/middlewares/parsers/schema.preprocessor.ts
Expand Up @@ -34,12 +34,10 @@ class Node<T, P> {
public readonly path: string[];
public readonly parent: P;
public readonly schema: T;
public readonly seen: boolean;
constructor(parent: P, schema: T, path: string[]) {
this.path = path;
this.parent = parent;
this.schema = schema;
this.seen = false;
}
}
type SchemaObjectNode = Node<SchemaObject, SchemaObject>;
Expand Down Expand Up @@ -172,13 +170,13 @@ export class SchemaPreprocessor {
private traverseSchemas(nodes: TopLevelSchemaNodes, visit) {
const recurse = (parent, node, opts: TraversalStates) => {
const schema = this.resolveSchema<SchemaObject>(node.schema);
if (node.seen || !schema) {
if (node.schema._seen || !schema) {
// if we can't dereference a path within the schema, skip preprocessing
// TODO handle refs like below during preprocessing
// #/paths/~1subscription/get/requestBody/content/application~1json/schema/properties/subscription
return;
}
node.seen = true;
node.schema._seen = true;
// Save the original schema so we can check if it was a $ref
(<any>opts).req.originalSchema = node.schema;
(<any>opts).res.originalSchema = node.schema;
Expand Down

0 comments on commit 617e9d3

Please sign in to comment.