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

Support APIGW Models in API Events #895

Closed
keetonian opened this issue Apr 23, 2019 · 4 comments
Closed

Support APIGW Models in API Events #895

keetonian opened this issue Apr 23, 2019 · 4 comments

Comments

@keetonian
Copy link
Contributor

keetonian commented Apr 23, 2019

It would be nice to add options to the API event source for AWS::Serverless::Function for models (request and response) and validators similar to how authorizers can be defined in there now without having to dive into swagger.

Originally posted by @beck3905 in #850 (comment)

Models in swagger: https://swagger.io/docs/specification/2-0/describing-request-body/ (see Object Payload section).

I think we should add models to the Serverless::Api resource and allow events to reference them:

Resource:
  Api:
    Type: AWS::Serverless::Api
    Properties:
      Models: # use swagger format to define models. This gets passed through to the `definitions` section of swagger.
        User:   
          type: object
          required:
            - userName
          properties:
            userName:
              type: string
            firstName:
              type: string
            lastName:
              type: string
     ...

  Function:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        ApiEvent:
          Type: Api
          Properties:
            RestApiId: !Ref Api
            RequestModel: User    # reference by string name
            ResponseModel: User  # reference by string name
@beck3905
Copy link
Contributor

@keetonian Thanks for creating this feature request. I may try to take a stab at it if I have time in the next month or so.

@beck3905
Copy link
Contributor

@keetonian I think this new feature request I created is related to this existing one: #931. Essentially, I envision adding optional properties to the API event source definition the correspond to the properties available on the AWS::ApiGateway::Method resource type: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-method.html. Then those properties if provided would be translated into the swagger definition for that method. What are your thoughts on this?

@keetonian
Copy link
Contributor Author

I think that this is a great idea and would be a good feature! Thank you for bringing this up.

@praneetap
Copy link
Contributor

Released with v1.13.0

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