esi / esi-issues

Issue tracking and feature requests for ESI
https://esi.evetech.net/
208 stars 23 forks source link

Swagger specification is not compliant according to go-swagger #653

Open iandelahorne opened 6 years ago

iandelahorne commented 6 years ago

The swagger specification is invalid, according to latest go-swagger against latest swagger.json:

$ swagger generate client
The swagger spec at "swagger.json" is invalid against swagger specification 2.0. see errors :
- type in /killmails/{killmail_id}/{killmail_hash}/.victim is required
- /corporations/{corporation_id}/containers/logs/.logged_at in body must be of type date-time: "2017-10-11T12:04:33"
- type in /characters/{character_id}/fittings/ is required

The second error, /corporations/{corporation_id}/containers/logs/.logged_at, is due to one of the examples logged_at missing a Z at the end of (i e 2017-10-11T12:04:33 -> 2017-10-11T12:04:33Z

As for the other two, no idea why those are failing.

cjslep commented 6 years ago

Still a problem:

$ swagger generate client -f https://esi.tech.ccp.is/swagger.json
The swagger spec at "https://esi.tech.ccp.is/swagger.json" is invalid against swagger specification 2.0. see errors :
- must validate one and only one schema (oneOf)
- must validate one and only one schema (oneOf)
- type in paths./versions/.get.responses.200.schema is required
- type in paths./versions/.get.responses.200.schema is required
- must validate one and only one schema (oneOf)
- must validate one and only one schema (oneOf)
- type in paths./versions/.get.responses.200.schema is required
- type in paths./versions/.get.responses.200.schema is required
- must validate one and only one schema (oneOf)
- must validate one and only one schema (oneOf)
- type in paths./versions/.get.responses.200.schema is required
- type in paths./versions/.get.responses.200.schema is required
- must validate one and only one schema (oneOf)
- must validate one and only one schema (oneOf)
- type in paths./versions/.get.responses.200.schema is required
- type in paths./versions/.get.responses.200.schema is required

Luckily it is a very easy fix:

curl https://esi.tech.ccp.is/swagger.json -O

Edit swagger.json. Look for:

{
  "/versions/": {
    "get": {
      "responses": {
        "200": {
          "schema": {
            // Add the following:
            "type": "array",
            // ...
          }
        }
      }
    }
  }
}

Then go-swagger will happily consume the file.

This was used with:

swagger version
version: 0.13.0
commit: 8135eb6728e43b73489e80f94426e6d387809502

And the ESI swagger.json specification used was the one available at 2017-12-15 20:18 UTC.

cjslep commented 6 years ago

I also forgot to talk about the main swagger-API, not just the meta:

$ curl https://esi.tech.ccp.is/latest/swagger.json -O
$ swagger generate client -f swagger.json 
The swagger spec at "swagger.json" is invalid against swagger specification 2.0. see errors :
- type in /killmails/{killmail_id}/{killmail_hash}/.victim is required
- type in /characters/{character_id}/fittings/ is required

This is an issue with github.com/go-openapi/validate, and I am filing a bug and failing test case for them. Having the nested "items" object within an array (which uses the "items" swagger keyword) is what is causing these to fail; and it seems to be go-specific.

I will provide a link once I file the bug against that project.

a-tal commented 6 years ago

meta spec titles & types have been updated

cjslep commented 6 years ago

The issue I filed is at: https://github.com/go-openapi/validate/issues/43

Workaround is to simply delete the get response example in /characters/{character_id}/fittings/; similarly for /killmails/{killmail_id}/{killmail_hash}/ which will allow go-swagger to successfully generate the code.