Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put collectionFormat in one place #28

Closed
fizruk opened this issue Dec 22, 2015 · 0 comments
Closed

Put collectionFormat in one place #28

fizruk opened this issue Dec 22, 2015 · 0 comments

Comments

@fizruk
Copy link
Member

fizruk commented Dec 22, 2015

For example, in ParamSchema. This might enable things like:

newtype CSV a = CSV { getCSV :: [a] }

instance ToParamSchema a => ToParamSchema (CSV a) where
  toParamSchema _ = mempty
    & schemaType .~ SwaggerArray
    & schemaCollectionFormat ?~ CollectionFormatCSV
    & schemaItems ?~ SwaggerItemsPrimitive (toParamSchema (Proxy :: Proxy a))

Alternatively we can leave it in Items, changing its meaning to "collection format of these items (always required)". Then CSV example above would look like this:

newtype CSV a = CSV { getCSV :: [a] }

instance ToParamSchema a => ToParamSchema (CSV a) where
  toParamSchema _ = mempty
    & schemaType .~ SwaggerArray
    & schemaItems ?~ SwaggerItemsPrimitive CollectionFormatCSV (toParamSchema (Proxy :: Proxy a))

If there is a solution where we can put collection format entirely out of schema — that would be preferable, since ParamSchema is contained in Schema and collection format does not make sense for the latter.

fizruk added a commit that referenced this issue Dec 24, 2015
This change places collection format in SwaggerItems.
@fizruk fizruk closed this as completed in 3cc860d Dec 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant