Skip to content

Commit

Permalink
fix(sdk): cloud.Api open api spec is overriden (#6053)
Browse files Browse the repository at this point in the history
## Checklist

- [ ] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [ ] Description explains motivation and solution
- [ ] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
eladcon authored Mar 25, 2024
1 parent ad9c114 commit dcd47d9
Show file tree
Hide file tree
Showing 31 changed files with 71 additions and 70 deletions.
76 changes: 38 additions & 38 deletions libs/awscdk/test/__snapshots__/api.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ exports[`api configured for cors 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA9006f966b9f7cd9b2b432eb5c29bb54b87c6": {
"Apiapideployment63AA9006a9350fdefb39f2c9c8b6f14c6d2d6da7": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -291,7 +291,7 @@ exports[`api configured for cors 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA9006f966b9f7cd9b2b432eb5c29bb54b87c6",
"Ref": "Apiapideployment63AA9006a9350fdefb39f2c9c8b6f14c6d2d6da7",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -551,7 +551,7 @@ exports[`api url can be used as environment variable 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA900631e48b71dd3d2a7c890c7b7740417862": {
"Apiapideployment63AA9006910767f1701c246578b56528c67217b8": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand All @@ -567,7 +567,7 @@ exports[`api url can be used as environment variable 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA900631e48b71dd3d2a7c890c7b7740417862",
"Ref": "Apiapideployment63AA9006910767f1701c246578b56528c67217b8",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -910,7 +910,7 @@ exports[`api with 'name' & 'age' parameter 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA90062f077666b7a242470d5f0af6cb54e2fa": {
"Apiapideployment63AA90064db664b7f484d24bf9fd7531027f96a0": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -960,7 +960,7 @@ exports[`api with 'name' & 'age' parameter 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA90062f077666b7a242470d5f0af6cb54e2fa",
"Ref": "Apiapideployment63AA90064db664b7f484d24bf9fd7531027f96a0",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -1271,7 +1271,7 @@ exports[`api with 'name' parameter 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA9006af4d0414e5191b586ce98d28f6b78244": {
"Apiapideployment63AA90062896733bcfed3fd7fed219dcae5c3b08": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -1321,7 +1321,7 @@ exports[`api with 'name' parameter 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA9006af4d0414e5191b586ce98d28f6b78244",
"Ref": "Apiapideployment63AA90062896733bcfed3fd7fed219dcae5c3b08",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -1623,7 +1623,7 @@ exports[`api with CONNECT route 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA90062eecb976b06b1a8aede012adc45cedd4": {
"Apiapideployment63AA90068c14f6305292724800daf2c66d8aab90": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -1673,7 +1673,7 @@ exports[`api with CONNECT route 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA90062eecb976b06b1a8aede012adc45cedd4",
"Ref": "Apiapideployment63AA90068c14f6305292724800daf2c66d8aab90",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -1975,7 +1975,7 @@ exports[`api with DELETE route 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA9006f5b6f478b64f41255a52bc405b0b1f59": {
"Apiapideployment63AA900652590e04c0874a94e1360f4a4761e33a": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -2025,7 +2025,7 @@ exports[`api with DELETE route 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA9006f5b6f478b64f41255a52bc405b0b1f59",
"Ref": "Apiapideployment63AA900652590e04c0874a94e1360f4a4761e33a",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -2327,7 +2327,7 @@ exports[`api with GET route at root 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA90065584d3a19d622308711306be2c779d45": {
"Apiapideployment63AA9006a3eb210ab6f4ad239a1e2ab7e70baf6c": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -2377,7 +2377,7 @@ exports[`api with GET route at root 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA90065584d3a19d622308711306be2c779d45",
"Ref": "Apiapideployment63AA9006a3eb210ab6f4ad239a1e2ab7e70baf6c",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -2721,7 +2721,7 @@ exports[`api with GET routes with common prefix 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA90067fe01ea071d08877f82be426b7fa297b": {
"Apiapideployment63AA9006628157807bd818497ef5f0c02bf60a24": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -2805,7 +2805,7 @@ exports[`api with GET routes with common prefix 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA90067fe01ea071d08877f82be426b7fa297b",
"Ref": "Apiapideployment63AA9006628157807bd818497ef5f0c02bf60a24",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -3225,7 +3225,7 @@ exports[`api with GET routes with different prefix 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA9006add14f5c19c807f63950eb89ae528da3": {
"Apiapideployment63AA90069af77ebae27120f9cb146237ccc602f1": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -3309,7 +3309,7 @@ exports[`api with GET routes with different prefix 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA9006add14f5c19c807f63950eb89ae528da3",
"Ref": "Apiapideployment63AA90069af77ebae27120f9cb146237ccc602f1",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -3687,7 +3687,7 @@ exports[`api with HEAD route 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA90064c4722c2255408b195925a72a6c54a91": {
"Apiapideployment63AA9006189f3dead8ebb5853ed30011eebac22c": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -3737,7 +3737,7 @@ exports[`api with HEAD route 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA90064c4722c2255408b195925a72a6c54a91",
"Ref": "Apiapideployment63AA9006189f3dead8ebb5853ed30011eebac22c",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -4039,7 +4039,7 @@ exports[`api with OPTIONS route 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA9006c72b16e492265df5697b564498a0bda0": {
"Apiapideployment63AA900640e913fb7156d92826ccb4d88cf00d94": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -4089,7 +4089,7 @@ exports[`api with OPTIONS route 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA9006c72b16e492265df5697b564498a0bda0",
"Ref": "Apiapideployment63AA900640e913fb7156d92826ccb4d88cf00d94",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -4391,7 +4391,7 @@ exports[`api with PATCH route 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA900622411480af77d5aa223a4a205574ac7a": {
"Apiapideployment63AA90064f5d9980a974eff1e3d61429956660fb": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -4441,7 +4441,7 @@ exports[`api with PATCH route 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA900622411480af77d5aa223a4a205574ac7a",
"Ref": "Apiapideployment63AA90064f5d9980a974eff1e3d61429956660fb",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -4743,7 +4743,7 @@ exports[`api with POST route 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA9006b51b5d701a7af604832597fab4d8cceb": {
"Apiapideployment63AA9006528a36383aa0f54328f5727d0d594f86": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -4793,7 +4793,7 @@ exports[`api with POST route 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA9006b51b5d701a7af604832597fab4d8cceb",
"Ref": "Apiapideployment63AA9006528a36383aa0f54328f5727d0d594f86",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -5095,7 +5095,7 @@ exports[`api with PUT route 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA900643b5463773184a42423009af11510ad4": {
"Apiapideployment63AA90062b5c6b2567f30a68924df13648507424": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -5145,7 +5145,7 @@ exports[`api with PUT route 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA900643b5463773184a42423009af11510ad4",
"Ref": "Apiapideployment63AA90062b5c6b2567f30a68924df13648507424",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -5489,7 +5489,7 @@ exports[`api with multiple GET route and one lambda 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA9006b8d83dac42ae9c9165969e69aa7ca2c6": {
"Apiapideployment63AA90062edea4fc086bea068dac779a93873489": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -5573,7 +5573,7 @@ exports[`api with multiple GET route and one lambda 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA9006b8d83dac42ae9c9165969e69aa7ca2c6",
"Ref": "Apiapideployment63AA90062edea4fc086bea068dac779a93873489",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -5917,7 +5917,7 @@ exports[`api with multiple methods and multiple lambda 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA9006797d89cd0cd50502221d9b261ead2166": {
"Apiapideployment63AA9006ae7d6e4a6052298d2abfbe41d9e1e06e": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -6001,7 +6001,7 @@ exports[`api with multiple methods and multiple lambda 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA9006797d89cd0cd50502221d9b261ead2166",
"Ref": "Apiapideployment63AA9006ae7d6e4a6052298d2abfbe41d9e1e06e",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -6421,7 +6421,7 @@ exports[`api with multiple methods and one lambda 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA9006a3018bfd9f41f9f0d3210e1e3fbf2b66": {
"Apiapideployment63AA90065e7c510d60086ba47477ff050abadbc9": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -6505,7 +6505,7 @@ exports[`api with multiple methods and one lambda 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA9006a3018bfd9f41f9f0d3210e1e3fbf2b66",
"Ref": "Apiapideployment63AA90065e7c510d60086ba47477ff050abadbc9",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -6847,7 +6847,7 @@ exports[`api with multiple methods on same route 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA90069d73ac8bd0a03c2fa1129cdb39ac09e2": {
"Apiapideployment63AA9006b1eeaaafc7f642195ca45ff4c51112c7": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -6931,7 +6931,7 @@ exports[`api with multiple methods on same route 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA90069d73ac8bd0a03c2fa1129cdb39ac09e2",
"Ref": "Apiapideployment63AA9006b1eeaaafc7f642195ca45ff4c51112c7",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down Expand Up @@ -7242,7 +7242,7 @@ exports[`api with path parameter 1`] = `
"Type": "AWS::IAM::Role",
"UpdateReplacePolicy": "Retain",
},
"Apiapideployment63AA9006a7a2bebf9e729cdf383b0ef6e3972bac": {
"Apiapideployment63AA90067964adf987057a6a86baf23dd82e2513": {
"DeletionPolicy": "Retain",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -7292,7 +7292,7 @@ exports[`api with path parameter 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "Apiapideployment63AA9006a7a2bebf9e729cdf383b0ef6e3972bac",
"Ref": "Apiapideployment63AA90067964adf987057a6a86baf23dd82e2513",
},
"RestApiId": {
"Ref": "Apiapi93AB445C",
Expand Down
1 change: 1 addition & 0 deletions libs/wingsdk/src/cloud/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ export class Api extends Resource {

// https://spec.openapis.org/oas/v3.0.3
return {
...this.apiSpec,
openapi: "3.0.3",
paths: paths,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ exports[`api will be private when vpc_api_gateway is true 1`] = `
},
"aws_api_gateway_rest_api": {
"Api_api_91C07D84": {
"body": "{"openapi":"3.0.3","paths":{"/{proxy+}":{"x-amazon-apigateway-any-method":{"produces":["application/json"],"x-amazon-apigateway-integration":{"type":"mock","requestTemplates":{"application/json":"\\n {\\"statusCode\\": 404}\\n "},"passthroughBehavior":"never","responses":{"404":{"statusCode":"404","responseParameters":{"method.response.header.Content-Type":"'application/json'"},"responseTemplates":{"application/json":"{\\"statusCode\\": 404, \\"message\\": \\"Error: Resource not found\\"}"}},"default":{"statusCode":"404","responseParameters":{"method.response.header.Content-Type":"'application/json'"},"responseTemplates":{"application/json":"{\\"statusCode\\": 404, \\"message\\": \\"Error: Resource not found\\"}"}}}},"responses":{"404":{"description":"404 response","headers":{"Content-Type":{"type":"string"}}}}}}}}",
"body": "{"paths":{"/{proxy+}":{"x-amazon-apigateway-any-method":{"produces":["application/json"],"x-amazon-apigateway-integration":{"type":"mock","requestTemplates":{"application/json":"\\n {\\"statusCode\\": 404}\\n "},"passthroughBehavior":"never","responses":{"404":{"statusCode":"404","responseParameters":{"method.response.header.Content-Type":"'application/json'"},"responseTemplates":{"application/json":"{\\"statusCode\\": 404, \\"message\\": \\"Error: Resource not found\\"}"}},"default":{"statusCode":"404","responseParameters":{"method.response.header.Content-Type":"'application/json'"},"responseTemplates":{"application/json":"{\\"statusCode\\": 404, \\"message\\": \\"Error: Resource not found\\"}"}}}},"responses":{"404":{"description":"404 response","headers":{"Content-Type":{"type":"string"}}}}}}},"openapi":"3.0.3"}",
"endpoint_configuration": {
"types": [
"PRIVATE",
Expand Down
Loading

0 comments on commit dcd47d9

Please sign in to comment.