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

AWS API Gateway compatability #113

Open
ivan-m opened this issue Aug 17, 2017 · 3 comments
Open

AWS API Gateway compatability #113

ivan-m opened this issue Aug 17, 2017 · 3 comments

Comments

@ivan-m
Copy link

ivan-m commented Aug 17, 2017

FYI: I've just found out from AWS technical support that the reason my generated (from servant-swagger) Swagger specification wasn't working was because they don't support the example field for objects/models.

It might be worth documenting this.

@fizruk
Copy link
Member

fizruk commented Feb 22, 2018

Note that you can remove example for every Schema in a Swagger document like this:

import Data.Data.Lens (template)

-- | Prepare a Swagger document for AWS.
-- Apparently AWS does not support 'example' property for Swagger Schema.
-- This function removes examples for all schemas.
swaggerForAWS :: Swagger -> Swagger
swaggerForAWS = allSchemas %~ example .~ Nothing
  where
    allSchemas :: Traversal' Swagger Schema
    allSchemas = template

It would still be nice to put the warning somewhere in the documentation.
Perhaps with the code above.

Maybe it can be worth to add swaggerForAWS helper (or a version of it) in the library too.

@bford-ff
Copy link

I know this is a bit of an old issue, but I've run into something related. I want to add a sections like this (in yaml format) to each of the paths in my swagger definition:

   x-amazon-apigateway-integration:
        uri: ${servant_lambda_arn}
        passthroughBehavior: "when_no_match"
        httpMethod: "POST" ### NOTE: This has to be POST, regardless of the actual api being get
        type: "aws_proxy"

I'm actually generating the whole of the swagger file from a servant API, which I'm deploying to AWS lambda with terraform - having the generated swagger be templated into the terraform set would be awesome. @fizruk @ivan-m - happy to send a PR if necessary or update any documentation if you can point me in the right direction...

@bford-ff
Copy link

It looks like I'd need to extend the Operation data type to make this work, perhaps a field like this? extensions :: Maybe Value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants