GetShopTV/swagger2

What part of Swagger spec describes SwaggerItemsArray?

Open

#107 opened on May 31, 2017

View on GitHub
 (6 comments) (0 reactions) (0 assignees)Haskell (61 forks)github user discovery
good first issuehelp wanted

Repository metrics

Stars
 (74 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

In our code I've tried using SwaggerItemsArray with the following ToSchema instance:

instance ToSchema QuartileCounts where
  declareNamedSchema _  = do
    iSchema <- declareSchemaRef (Proxy @ (Sum Integer))
    return . named "QuartileCounts" $ mempty
      & type_ .~ SwaggerArray
      & items ?~ SwaggerItemsArray [iSchema, iSchema, iSchema, iSchema]

which should cover as I understand values like e.g. [21, 6, 4, 1]. But with a swagger.json for that Python client (which uses bravado to access Swagger endpoints) on unmarshaling line:

obj_type = schema_object_spec.get('type')

And it looks like according to the spec (as shown at http://swagger.io/specification/#itemsObject or https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#itemsObject ) items property should be a "Items Object" and not an array. For our case I'll go with SwaggerItemsObject as this "tuple" is homogeneous but what about other tuples - at the moment it looks to me that swagger file generated with swagger2 will be incorrect.

Contributor guide