Skip to content

Commit

Permalink
fix: check if OpenApiVersion matches to openapi value in DefinitionBody
Browse files Browse the repository at this point in the history
  • Loading branch information
xazhao committed Feb 27, 2024
1 parent e302b20 commit 7f998e1
Show file tree
Hide file tree
Showing 7 changed files with 3,035 additions and 0 deletions.
9 changes: 9 additions & 0 deletions samtranslator/model/api/api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,15 @@ def _openapi_postprocess(self, definition_body: Dict[str, Any]) -> Dict[str, Any
if definition_body.get("openapi") is not None and self.open_api_version is None:
self.open_api_version = definition_body.get("openapi")

if (
definition_body.get("openapi") is not None
and self.open_api_version is not None
and definition_body.get("openapi") != self.open_api_version
):
raise InvalidResourceException(
self.logical_id, "OpenApiVersion property doesn't match openapi value in 'DefinitionBody'."
)

if self.open_api_version and SwaggerEditor.safe_compare_regex_with_string(
SwaggerEditor._OPENAPI_VERSION_3_REGEX, self.open_api_version
):
Expand Down
Loading

0 comments on commit 7f998e1

Please sign in to comment.