OpenAPI-Specification icon indicating copy to clipboard operation
OpenAPI-Specification copied to clipboard

Possible bug in petstore-simple.json swagger 2.0 example

Open christav opened this issue 11 years ago • 2 comments

I'm looking at writing some tooling around swagger 2.0, and I'm starting with the examples in the repo here. However, I've found something that looks to me like a bug in the example. I'd love some advice on if this is in fact an error or if I'm reading things incorrectly.

In https://github.com/swagger-api/swagger-spec/blob/master/examples/v2.0/json/petstore-simple.json, starting at line 190, is:

    "petInput": {
      "allOf": [
        {
          "$ref": "pet"
        },
        {
          "required": [
            "name"
          ],
          "properties": {
            "id": {
              "type": "integer",
              "format": "int64"
            }
          }
        }
      ]
    },

So the weird bit is that the "required" section specifies "name", while the properties object doesn't include a name property. Based on my reading of the JSON schema spec, this will result in invalid json in all cases, since there's a required property (name) that isn't in the properties object.

Is this an error in the example, or is there more semantics here that I'm not aware of?

Also, my reading of the "allOf" entry indicates that valid json for this schema requires that the object meet all the validation requirements of all the referenced schemas. However, in this case the properties (id and maybe name?) are a string subset of the "pet" schema, so it looks like the allOf in this case doesn't actually mean anything useful here. Is this understanding correct?

christav avatar Jan 28 '15 00:01 christav

Thank you for the issue, but it's a duplicate of #192. The sample is wrong in many aspects and I'm working on getting it fixed. Please subscribe to the other issue for updates.

webron avatar Jan 28 '15 01:01 webron

Darn it - I thought I'd scoured the repo for this issue already. Thanks for pointing out the original, I'll track there.

christav avatar Jan 28 '15 01:01 christav