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

fix: openapi postprocess bug in request models with security definitions #990

Merged
merged 11 commits into from
Jun 24, 2019

Conversation

praneetap
Copy link
Contributor

@praneetap praneetap commented Jun 22, 2019

Issue #, if available:
securityDefinitions don't get changed to components/securitySchemes if request models are defined, and this breaks the cloudformation deployment.
Description of changes:
Moved openapi postprocess to a single function.
Description of how you validated changes:
Wrote unit tests
Deployed the following template successfully on cfn

Resources:
  MyApi:
    Type: AWS::Serverless::Api
    Properties:
      OpenApiVersion: 3.0.1
      StageName: Prod
      Models:
        User:
          type: object
          properties:
            username:
              type: string

  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs8.10
      InlineCode: |
        exports.handler = async (event, context, callback) => {
          return {
            statusCode: 200,
            body: 'Success'
          }
        }
      Events:
        Iam:
          Type: Api
          Properties:
            RequestModel:
              Model: User
              Required: true
            RestApiId:
              Ref: MyApi
            Method: get
            Path: /iam
            Auth:
              Authorizer: AWS_IAM
Outputs:
  ApiUrl:
    Description: "API endpoint URL for Prod environment"
    Value:
      Fn::Sub: 'https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/'

Checklist:

  • Write/update tests
  • make pr passes
  • Update documentation
  • Verify transformed template deploys and application functions as expected
  • Add/update example to examples/2016-10-31

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-io
Copy link

codecov-io commented Jun 22, 2019

Codecov Report

Merging #990 into release/v1.13.0 will increase coverage by 0.14%.
The diff coverage is 87.5%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           release/v1.13.0     #990      +/-   ##
===================================================
+ Coverage            94.71%   94.86%   +0.14%     
===================================================
  Files                   69       69              
  Lines                 3160     3152       -8     
  Branches               606      602       -4     
===================================================
- Hits                  2993     2990       -3     
+ Misses                  85       84       -1     
+ Partials                82       78       -4
Impacted Files Coverage Δ
samtranslator/model/api/api_generator.py 95.33% <87.5%> (+1.74%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88df20c...82fb271. Read the comment docs.

@praneetap praneetap merged commit 4efb9df into aws:release/v1.13.0 Jun 24, 2019
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

Successfully merging this pull request may close these issues.

4 participants