From 61711c5b52270fc073cc282e3430c97f39541acc Mon Sep 17 00:00:00 2001 From: Chris Rehn Date: Fri, 20 Jan 2023 11:47:28 -0800 Subject: [PATCH 1/2] chore: better property title --- samtranslator/schema/schema.json | 4 +--- samtranslator/schema/schema.py | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/samtranslator/schema/schema.json b/samtranslator/schema/schema.json index b5c6e2e6f..340c0e7ba 100644 --- a/samtranslator/schema/schema.json +++ b/samtranslator/schema/schema.json @@ -155547,9 +155547,7 @@ ], "type": "object" }, - "PassThroughProp": { - "title": "PassThroughProp" - }, + "PassThroughProp": {}, "PrimaryKey": { "additionalProperties": false, "properties": { diff --git a/samtranslator/schema/schema.py b/samtranslator/schema/schema.py index cbd84fdfe..c54f0ba75 100644 --- a/samtranslator/schema/schema.py +++ b/samtranslator/schema/schema.py @@ -105,6 +105,11 @@ def extend_with_cfn_schema(sam_schema: Dict[str, Any], cfn_schema: Dict[str, Any # The unified schema should include all supported properties sam_schema["additionalProperties"] = False + # Pydantic automatically adds title to model (https://github.com/pydantic/pydantic/issues/1051), + # and the YAML extension for VS Code then shows 'PassThroughProp' as title for pass-through + # properties (instead of the title of the property itself)... so manually deleting it. + del sam_schema["definitions"]["PassThroughProp"]["title"] + def main() -> None: parser = argparse.ArgumentParser() From f14f9cbef4c56f7267c438141cca262c5487f2ad Mon Sep 17 00:00:00 2001 From: Chris Rehn Date: Fri, 20 Jan 2023 11:59:00 -0800 Subject: [PATCH 2/2] Also in SAM schema --- samtranslator/schema/sam.schema.json | 4 +--- samtranslator/schema/schema.py | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/samtranslator/schema/sam.schema.json b/samtranslator/schema/sam.schema.json index 2d93693a0..55ba18fb2 100644 --- a/samtranslator/schema/sam.schema.json +++ b/samtranslator/schema/sam.schema.json @@ -2016,9 +2016,7 @@ "title": "OAuth2Authorizer", "type": "object" }, - "PassThroughProp": { - "title": "PassThroughProp" - }, + "PassThroughProp": {}, "PrimaryKey": { "additionalProperties": false, "properties": { diff --git a/samtranslator/schema/schema.py b/samtranslator/schema/schema.py index c54f0ba75..8f705a24c 100644 --- a/samtranslator/schema/schema.py +++ b/samtranslator/schema/schema.py @@ -69,6 +69,11 @@ def get_schema(model: Type[pydantic.BaseModel]) -> Dict[str, Any]: # Validated in https://github.com/aws/serverless-application-model/blob/5c82f5d2ae95adabc9827398fba8ccfc3dbe101a/tests/schema/test_validate_schema.py#L91 obj["$schema"] = "http://json-schema.org/draft-04/schema#" + # Pydantic automatically adds title to model (https://github.com/pydantic/pydantic/issues/1051), + # and the YAML extension for VS Code then shows 'PassThroughProp' as title for pass-through + # properties (instead of the title of the property itself)... so manually deleting it. + del obj["definitions"]["PassThroughProp"]["title"] + return obj @@ -105,11 +110,6 @@ def extend_with_cfn_schema(sam_schema: Dict[str, Any], cfn_schema: Dict[str, Any # The unified schema should include all supported properties sam_schema["additionalProperties"] = False - # Pydantic automatically adds title to model (https://github.com/pydantic/pydantic/issues/1051), - # and the YAML extension for VS Code then shows 'PassThroughProp' as title for pass-through - # properties (instead of the title of the property itself)... so manually deleting it. - del sam_schema["definitions"]["PassThroughProp"]["title"] - def main() -> None: parser = argparse.ArgumentParser()