Use default values for non-required properties if a default is specified (#254)

* use default values for non-required properties if a default is specified

* generate client

* I have generated the latest API!

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Greg Sweeney
2024-08-20 13:10:56 -04:00
committed by GitHub
parent 70037b7459
commit 556ec31ca2
53 changed files with 1018 additions and 982 deletions

View File

@ -1669,7 +1669,15 @@ def generateObjectTypeCode(
else:
field_type = getTypeName(property_schema)
if property_name not in required:
field_type = "Optional[" + field_type + "] = None"
if "default" in property_schema:
field_type += (
' = "' + property_schema["default"] + '"'
if field_type == "str"
or isinstance(property_schema["default"], str)
else " = " + str(property_schema["default"])
)
else:
field_type = "Optional[" + field_type + "] = None"
field2: FieldType = {
"name": property_name,
"type": field_type,