Skip to content

Commit

Permalink
Revert "fix: normalize the open api version (#3551)"
Browse files Browse the repository at this point in the history
This reverts commit 6499b50.
  • Loading branch information
aaythapa authored Mar 8, 2024
1 parent bc785e5 commit 0b071db
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 1,161 deletions.
12 changes: 7 additions & 5 deletions samtranslator/model/api/api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def __init__( # noqa: PLR0913
self.resource_attributes = resource_attributes
self.passthrough_resource_attributes = passthrough_resource_attributes
self.open_api_version = open_api_version
self.remove_extra_stage = open_api_version
self.models = models
self.domain = domain
self.fail_on_warnings = fail_on_warnings
Expand Down Expand Up @@ -399,7 +400,7 @@ def _construct_deployment(self, rest_api: ApiGatewayRestApi) -> ApiGatewayDeploy
self.logical_id + "Deployment", attributes=self.passthrough_resource_attributes
)
deployment.RestApiId = rest_api.get_runtime_attr("rest_api_id")
if not self.open_api_version:
if not self.remove_extra_stage:
deployment.StageName = "Stage"

return deployment
Expand Down Expand Up @@ -437,7 +438,7 @@ def _construct_stage(
if swagger is not None:
deployment.make_auto_deployable(
stage,
self.open_api_version,
self.remove_extra_stage,
swagger,
self.domain,
redeploy_restapi_parameters,
Expand Down Expand Up @@ -1124,10 +1125,11 @@ def _openapi_postprocess(self, definition_body: Dict[str, Any]) -> Dict[str, Any
if definition_body.get("swagger") is not None:
return definition_body

normalized_open_api_version = definition_body.get("openapi", self.open_api_version)
if definition_body.get("openapi") is not None and self.open_api_version is None:
self.open_api_version = definition_body.get("openapi")

if normalized_open_api_version and SwaggerEditor.safe_compare_regex_with_string(
SwaggerEditor._OPENAPI_VERSION_3_REGEX, normalized_open_api_version
if self.open_api_version and SwaggerEditor.safe_compare_regex_with_string(
SwaggerEditor._OPENAPI_VERSION_3_REGEX, self.open_api_version
):
if definition_body.get("securityDefinitions"):
components = definition_body.get("components", Py27Dict())
Expand Down
166 changes: 0 additions & 166 deletions tests/translator/input/api_open_api_version_override.yaml

This file was deleted.

165 changes: 0 additions & 165 deletions tests/translator/input/error_api_openapi_not_set.yaml

This file was deleted.

Loading

0 comments on commit 0b071db

Please sign in to comment.