swagger-api / validator-badge

Validate your Swagger JSON/YAML today!
http://swagger.io
Apache License 2.0
210 stars 85 forks source link

incorrect validation errors when using global path parameters #137

Closed dolmen closed 5 years ago

dolmen commented 5 years ago

Here a spec extract that the validator reports as invalid, which it isn't:

{
  "messages": [
    "attribute paths.'/pet/{petId}'. Declared path parameter petId needs to be defined as a path parameter in path or operation level"
  ]
}

Spec extract:

parameters:
  petId:
    name: "petId"
    in: "path"
    description: "ID of pet to return"
    required: true
    type: "integer"
    format: "int64"
paths:
  /pet/{petId}:
    parameters:
    - $ref: "#/parameters/petId"
    get:
      tags:
      - "pet"
      summary: "Find pet by ID"
      description: "Returns a single pet"
      operationId: "getPetById"
      produces:
      - "application/json"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/Pet"

Full spec: https://gist.githubusercontent.com/dolmen/a8df78a79503d71307bb8f6c30544550/raw/55d3b2b506dff1e63e271b91829ae07428edc02c/mini-pet.yaml

drewish commented 5 years ago

Also getting bit by this. Looking through the history it doesn't seem like there was a code change in this library so seems more likely it was due to a bumped dependency version.

drewish commented 5 years ago

Ah, seems like https://github.com/swagger-api/swagger-parser/issues/976 is closer to the root of this.

drewish commented 5 years ago

https://github.com/swagger-api/swagger-parser/pull/977 was merged that should fix this but I'm still seeing these errors with the swagger validator. Does it need to have a version bump before it's fixed?

paxos commented 5 years ago

Would be nice to get this deployed soon :)

kevinsandow commented 4 years ago

Does the validator need a requirement bump? Still getting this for the initial example:

https://online.swagger.io/validator/debug?url=https://gist.githubusercontent.com/dolmen/a8df78a79503d71307bb8f6c30544550/raw/55d3b2b506dff1e63e271b91829ae07428edc02c/mini-pet.yaml

frantuma commented 4 years ago

Thanks for reporting this, it was indeed outdated, it is updated now. Also I suggest to switch to the new version of swagger-validator, supporting both Swagger/OpenAPI 2.0 and OpenAPI 3.0, available at https://validator.swagger.io and accepting the same requests as the instance on online.swagger.io