You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When opening a document with invalid spec, during the decoding of a document regardless of bypassing the document check, we ignore any errors that come up from decoding (ex. _ = parsedNode.Decode(&jsonSpec)). parsing code re-used
Expected Behavior
If we set bypass=false (or some new configuration, if preferred), we should not ignore any errors that happen during decoding.
Reproduction
I linked a branch in Extra Information, but the example spec used for this is:
openapi: "3.0.1"info:
version: 1.0.0description: This is a sample server Petstore server.title: Swagger Petstorelicense:
name: MITservers:
- url: http://petstore.swagger.io/v1paths:
/pets:
get:
summary: List all petsoperationId: listPetstags:
- petsparameters:
- name: limitin: querydescription: How many items to return at one time (max 100)required: falseschema:
type: integermaximum: 100format: int32responses:
'200':
description: A paged array of petsheaders:
x-next:
description: A link to the next page of responsesschema:
type: stringcontent:
application/json:
schema:
$ref: "#/components/schemas/Pets"default:
description: unexpected errorcontent:
application/json:
schema:
$ref: "#/components/schemas/Error"post:
summary: Create a petoperationId: createPetstags:
- petsrequestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'required: trueresponses:
'201':
description: Null responsedefault:
description: unexpected errorcontent:
application/json:
schema:
$ref: "#/components/schemas/Error"/pets/{petId}:
get:
summary: Info for a specific petoperationId: showPetByIdtags:
- petsparameters:
- name: petIdin: pathrequired: truedescription: The id of the pet to retrieveschema:
type: stringresponses:
'200':
description: Expected response to a valid requestcontent:
application/json:
schema:
$ref: "#/components/schemas/Pet"default:
description: unexpected errorcontent:
application/json:
schema:
$ref: "#/components/schemas/Error"components:
schemas:
Pet:
type: objectrequired:
- id
- nameproperties:
id:
type: integerformat: int64name:
type: stringtag:
type: stringPets:
type: arraymaxItems: 100items:
$ref: "#/components/schemas/Pet"Error:
type: objectrequired:
- code
- messageproperties:
code:
type: integerformat: int32message:
type: string
As you can see, the doc has a malindented second path. This should result in an error during decoding - which it does, but it is dropped (_). Technically the get(?) operation is set twice, since the second path + its operation is just treated as values for the first path, which is why this is a JSON/YAML issue.
Side Note: If you change the second path's operation to something else (put), then it technically would be valid JSON/YAML and would decode properly. At this point, the API doc would be invalid; I already tested that it results in an error through libopenapi-validator, which is good.
Issue
When opening a document with invalid spec, during the decoding of a document regardless of
bypass
ing the document check, we ignore any errors that come up from decoding (ex._ = parsedNode.Decode(&jsonSpec)
). parsing code re-usedExpected Behavior
If we set
bypass=false
(or some new configuration, if preferred), we should not ignore any errors that happen during decoding.Reproduction
I linked a branch in Extra Information, but the example spec used for this is:
As you can see, the doc has a malindented second path. This should result in an error during decoding - which it does, but it is dropped (
_
). Technically the get(?) operation is set twice, since the second path + its operation is just treated as values for the first path, which is why this is a JSON/YAML issue.Side Note: If you change the second path's operation to something else (put), then it technically would be valid JSON/YAML and would decode properly. At this point, the API doc would be invalid; I already tested that it results in an error through
libopenapi-validator
, which is good.Extra Information
libopenapi-validator
with the example doc used to reproduce this (error being ignored): https://github.com/pb33f/libopenapi-validator/compare/main...inFocus7:libopenapi-validator:102/fix-malindented-path-validation?expand=1next
version) results in the error we'd expect during decoding.The text was updated successfully, but these errors were encountered: