Skip to content

fix: better property title #2800

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

Merged
merged 2 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions samtranslator/schema/sam.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2016,9 +2016,7 @@
"title": "OAuth2Authorizer",
"type": "object"
},
"PassThroughProp": {
"title": "PassThroughProp"
},
"PassThroughProp": {},
"PrimaryKey": {
"additionalProperties": false,
"properties": {
Expand Down
4 changes: 1 addition & 3 deletions samtranslator/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -155547,9 +155547,7 @@
],
"type": "object"
},
"PassThroughProp": {
"title": "PassThroughProp"
},
"PassThroughProp": {},
"PrimaryKey": {
"additionalProperties": false,
"properties": {
Expand Down
5 changes: 5 additions & 0 deletions samtranslator/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down