Skip to content
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: 3 additions & 1 deletion openapitools.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"generatorName": "python",
"inputSpec": "public_accessa/api/v2/docs/cb-v2-openapi-3.0.0.yaml",
"outputDir": ".",
"templateDir": "templates",
"additionalProperties": {
"packageName": "cloudbeds_pms",
"projectName": "Cloudbeds PMS",
"packageVersion": "2.9.0",
"packageDescription": "OpenAPI client for Cloudbeds PMS API.",
"generateSourceCodeOnly": true,
"packageUrl": "https://github.com/cloudbeds/cloudbeds-api-python"
"packageUrl": "https://github.com/cloudbeds/cloudbeds-api-python",
"enumUnknownDefaultCase": true
},
"files": {
"README_onlypackage.mustache": {
Expand Down
34 changes: 34 additions & 0 deletions templates/model_enum.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from __future__ import annotations
import json
from enum import Enum
{{#vendorExtensions.x-py-other-imports}}
{{{.}}}
{{/vendorExtensions.x-py-other-imports}}
from typing_extensions import Self


class {{classname}}({{vendorExtensions.x-py-enum-type}}, Enum):
"""
{{{description}}}{{^description}}{{{classname}}}{{/description}}
"""

"""
allowed enum values
"""
{{#allowableValues}}
{{#enumVars}}
{{{name}}} = {{{value}}}
{{/enumVars}}

@classmethod
def from_json(cls, json_str: str) -> Self:
"""Create an instance of {{classname}} from a JSON string"""
return cls(json.loads(json_str))

{{#enumUnknownDefaultCase}}
@classmethod
def _missing_(cls, value):
"""Handle unknown enum values by returning the unknown default case."""
return cls.UNKNOWN_DEFAULT_OPEN_API
{{/enumUnknownDefaultCase}}
{{/allowableValues}}
Loading