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

feat: cors httpapi #1381

Merged
merged 20 commits into from
Feb 28, 2020
Merged

Conversation

ShreyaGangishetty
Copy link

@ShreyaGangishetty ShreyaGangishetty commented Jan 13, 2020

Issue #, if available:
#1295

Description of changes:

Description of how you validated changes:

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 Jan 13, 2020

Codecov Report

Merging #1381 into develop will decrease coverage by 0.42%.
The diff coverage is 63.63%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1381      +/-   ##
===========================================
- Coverage    94.36%   93.93%   -0.43%     
===========================================
  Files           78       78              
  Lines         4685     4686       +1     
  Branches       937      953      +16     
===========================================
- Hits          4421     4402      -19     
- Misses         121      132      +11     
- Partials       143      152       +9
Impacted Files Coverage Δ
samtranslator/plugins/globals/globals.py 99.02% <ø> (-0.03%) ⬇️
samtranslator/model/sam_resources.py 94.05% <ø> (-0.02%) ⬇️
samtranslator/model/api/http_api_generator.py 89.55% <57.14%> (-8.57%) ⬇️
samtranslator/open_api/open_api.py 90.19% <70.37%> (-3.32%) ⬇️
samtranslator/plugins/exceptions.py 83.33% <0%> (-2.39%) ⬇️
samtranslator/model/iam.py 92.85% <0%> (-1.43%) ⬇️
samtranslator/translator/arn_generator.py 86.95% <0%> (-0.55%) ⬇️
samtranslator/model/sqs.py 93.33% <0%> (-0.42%) ⬇️
samtranslator/validator/validator.py 95.23% <0%> (-0.42%) ⬇️
... and 12 more

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 77fa3b9...5ddd1b0. Read the comment docs.

DefinitionBody:
info:
version: '1.0'
title:
Ref: AWS::StackName
# when this is specified `CorsConfiguration` property is ignored
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question about this. What we need to decide is if CorsConfiguration should override, merge, or be ignored if there already exists a configuration in the openapi document.

This brings up the bigger question of how do we do this in other areas of SAM for HTTP APIs. I will need to check on this, but I believe that:

  • If a configuration doesn't exist in the openapi document, SAM should add it
  • If a configuration exists, SAM should have a set pattern of either ignoring or overriding it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed offline, I think we need to merge the CorsConfiguration with open api cors extension header if exists and override by giving preference to values in CorsConfiguration property. This way SAM can give the flexibility for template authors to override some of the cors headers mentioned in CorsConfiguration property and also will be able to add other/new Cors headers irrespective of SAMs support

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the code to merge and override CorsConfiguration

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are now ignoring the configurations here if there is a corresponding configuration in CorsConfiguration (remove comment)

tests/translator/input/http_api_explicit_stage.yaml Outdated Show resolved Hide resolved
@alexw91
Copy link

alexw91 commented Feb 21, 2020

Codecov Report

Merging #1381 into develop will decrease coverage by 0.34%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1381      +/-   ##
===========================================
- Coverage    94.36%   94.01%   -0.35%     
===========================================
  Files           78       78              
  Lines         4685     4779      +94     
  Branches       937      965      +28     
===========================================
+ Hits          4421     4493      +72     
- Misses         121      133      +12     
- Partials       143      153      +10     

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 77fa3b9...5cd7618. Read the comment docs.

samtranslator/model/api/http_api_generator.py Outdated Show resolved Hide resolved
samtranslator/model/api/http_api_generator.py Outdated Show resolved Hide resolved
samtranslator/model/api/http_api_generator.py Outdated Show resolved Hide resolved
Copy link
Contributor

@praneetap praneetap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work so far! few comments in the review.

samtranslator/model/api/http_api_generator.py Outdated Show resolved Hide resolved
samtranslator/model/api/http_api_generator.py Outdated Show resolved Hide resolved
samtranslator/model/api/http_api_generator.py Outdated Show resolved Hide resolved
samtranslator/model/api/http_api_generator.py Show resolved Hide resolved
samtranslator/model/sam_resources.py Outdated Show resolved Hide resolved
samtranslator/model/api/http_api_generator.py Show resolved Hide resolved
@ShreyaGangishetty ShreyaGangishetty changed the title Cors httpapi feat: cors httpapi Feb 26, 2020
@ShreyaGangishetty ShreyaGangishetty changed the base branch from develop to master February 27, 2020 17:42
@ShreyaGangishetty ShreyaGangishetty changed the base branch from master to develop February 27, 2020 17:42
@codecov-io
Copy link

codecov-io commented Feb 27, 2020

Codecov Report

❗ No coverage uploaded for pull request base (develop@5088d94). Click here to learn what that means.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop    #1381   +/-   ##
==========================================
  Coverage           ?   94.14%           
==========================================
  Files              ?       78           
  Lines              ?     4780           
  Branches           ?      965           
==========================================
  Hits               ?     4500           
  Misses             ?      130           
  Partials           ?      150
Impacted Files Coverage Δ
samtranslator/plugins/globals/globals.py 99.05% <ø> (ø)
samtranslator/model/sam_resources.py 94.09% <ø> (ø)
samtranslator/model/api/http_api_generator.py 93.19% <66.66%> (ø)

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 5088d94...6b9deb1. Read the comment docs.

DefinitionBody:
info:
version: '1.0'
title:
Ref: AWS::StackName
# when this is specified `CorsConfiguration` property is ignored
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are now ignoring the configurations here if there is a corresponding configuration in CorsConfiguration (remove comment)

samtranslator/model/api/http_api_generator.py Outdated Show resolved Hide resolved
samtranslator/model/api/http_api_generator.py Outdated Show resolved Hide resolved
@ShreyaGangishetty
Copy link
Author

In this PR, CorsConfiguration overrides the open api specification when intrinsic functions are present instead of merging both because it is not possible to resolve all the combinations of intrinsics at open api level.

@alexw91
Copy link

alexw91 commented Feb 28, 2020

Codecov Report

Merging #1381 into develop will decrease coverage by 0.25%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1381      +/-   ##
===========================================
- Coverage    94.40%   94.14%   -0.26%     
===========================================
  Files           78       78              
  Lines         4716     4780      +64     
  Branches       948      965      +17     
===========================================
+ Hits          4452     4500      +48     
- Misses         121      130       +9     
- Partials       143      150       +7     

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 b834f89...6b9deb1. Read the comment docs.

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.

5 participants