express-openapi-validator icon indicating copy to clipboard operation
express-openapi-validator copied to clipboard

Adding parameters to path invalidates entire document

Open JannickOste opened this issue 2 years ago • 1 comments

Describe the bug Invalid openAPIV3 spec document when building with parameters, invalidates the entire document. (doesn't happen with query variables, only path parameters)

To Reproduce Add a query parameter.

Actual behavior openapi.validator: validation errors [ { "instancePath": "/paths/~1dialogues~1id~1{id}/get/parameters/0/in", "schemaPath": "#/definitions/ParameterLocation/oneOf/0/properties/in/enum", "keyword": "enum", "params": { "allowedValues": [ "path" ] }, "message": "must be equal to one of the allowed values" }, { "instancePath": "/paths/~1dialogues~1id~1{id}/get/parameters/0/in", "schemaPath": "#/definitions/ParameterLocation/oneOf/1/properties/in/enum", "keyword": "enum", "params": { "allowedValues": [ "query" ] }, "message": "must be equal to one of the allowed values" }, { "instancePath": "/paths/~1dialogues~1id~1{id}/get/parameters/0/in", "schemaPath": "#/definitions/ParameterLocation/oneOf/2/properties/in/enum", "keyword": "enum", "params": { "allowedValues": [ "header" ] }, "message": "must be equal to one of the allowed values" }, { "instancePath": "/paths/~1dialogues~1id~1{id}/get/parameters/0/in", "schemaPath": "#/definitions/ParameterLocation/oneOf/3/properties/in/enum", "keyword": "enum", "params": { "allowedValues": [ "cookie" ] }, "message": "must be equal to one of the allowed values" }, { "instancePath": "/paths/~1dialogues~1id~1{id}/get/parameters/0", "schemaPath": "#/definitions/ParameterLocation/oneOf", "keyword": "oneOf", "params": { "passingSchemas": null }, "message": "must match exactly one schema in oneOf" }, { "instancePath": "/paths/~1dialogues~1id~1{id}/get/parameters/0", "schemaPath": "#/definitions/Reference/required", "keyword": "required", "params": { "missingProperty": "$ref" }, "message": "must have required property '$ref'" }, { "instancePath": "/paths/~1dialogues~1id~1{id}/get/parameters/0", "schemaPath": "#/properties/parameters/items/oneOf", "keyword": "oneOf", "params": { "passingSchemas": null }, "message": "must match exactly one schema in oneOf" } ]

Expected behavior No error

Examples and context My spec document (generated by custom spec builder) { "openapi": "3.0.0", "info": { "title": "API service example", "version": "0.1" }, "paths": { "/dialogues/id/{id}": { "get": { "summary": "Get a dialogue based on it's ID.", "parameters": [ { "in": "id", "name": "id", "required": true, "schema": { "type": "number" } } ], "responses": { "200": { "description": "The dialogue entity matching the specified ID parameter", "content": { "application/json": { "schema": { "additionalProperties": false, "type": "object", "properties": { "id": { "type": "number" }, "title": { "type": "string" }, "linesCSV": { "type": "string" } }, "required": [ "title", "linesCSV" ] } } } }, "400": { "description": "Bad request - fields not supplied", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" } }, "required": [ "error" ] } } } }, "404": { "description": "No dialogue found matching the ID", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" } }, "required": [ "error" ] } } } } } } } }, "components": { "schemas": {} }, "servers": [ { "url": "http://localhost:8080" }, { "url": "https://localhost:8081" } ] }

JannickOste avatar Jan 30 '23 10:01 JannickOste

It says ... "parameters": [ { "in": "id", .... Shouldn't that be "in": "path"?

openreply-dleinhaeuser avatar Jun 16 '23 06:06 openreply-dleinhaeuser