APIDevTools / swagger-parser

Swagger 2.0 and OpenAPI 3.0 parser/validator
https://apitools.dev/swagger-parser
MIT License
1.09k stars 154 forks source link

Validate is passing an invalide OpenAPi file #163

Closed acotty closed 3 years ago

acotty commented 3 years ago

The following file below passed the valid function, but fails when loaded into https://editor.swagger.io/

The https://editor.swagger.io/ errors are: Semantic error at paths./add/{x}/{y} Declared path parameter "x" needs to be defined as a path parameter at either the path or operation level Jump to line 13 Semantic error at paths./add/{x}/{y} Declared path parameter "y" needs to be defined as a path parameter at either the path or operation level Jump to line 13 Semantic error at paths./add/{x}/{y}.get.requestBody GET operations cannot have a requestBody. Jump to line 19

The openAPI dodgy file is: openapi: 3.0.0 info: title: Example API description: Example API version: 0.0.1 license: name: Restricted

servers:

url: /

paths: "/add/{x}/{y}": x-swagger-router-controller: math get: summary: Get the sum of two numbers. description: X + Y = JSON operationId: add requestBody: description: X + Y = JSON required: true content: application/json: schema: type: object properties: x: description: Left operand type: number y: description: Right operand type: number application/xml: schema: $ref: '#/components/schemas/Add' responses: "200": description: The product of numbers. x-gulp-swagger-codegen-outcome: success content: "/": schema: $ref: "#/components/schemas/BinaryResult" '400': description: Bad request x-gulp-swagger-codegen-outcome: badRequestError '405': description: Bad input data x-gulp-swagger-codegen-outcome: badInputError content: "/": schema: $ref: "#/components/schemas/ExceptionResponse" "500": x-gulp-swagger-codegen-outcome: error description: Error content: "/": schema: $ref: "#/components/schemas/ExceptionResponse"

components: schemas:

Add: description: A result from a binary operation. type: object required:

BinaryResult: description: A result from a binary operation. type: object required:

acotty commented 3 years ago

I have given up on this being fixed and have changed to use openapi-enforcer as it works better.