Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ public String toRegularExpression(String pattern) {
return addRegularExpressionDelimiter(pattern);
}

@Override
public boolean isRemoveEnumValuePrefix() {
// Python enum models do not currently support removing any common prefixes.
return false;
}

@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,21 @@ components:
- ZWEI
- DREI
default: ZWEI
EnumWithCommonPrefix:
type: string
example: V_T_2
enum:
- V_MORE_1
- V_T_2
- V_MULT_3
default: V_T_2
TestModel:
type: object
required:
- test_enum
properties:
test_enum_common_prefix:
$ref: "#/components/schemas/EnumWithCommonPrefix"
test_enum:
$ref: "#/components/schemas/TestEnum"
test_string:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2854,11 +2854,21 @@ components:
- ZWEI
- DREI
default: ZWEI
EnumWithCommonPrefix:
type: string
example: VAL_2
enum:
- VAL_1
- VAL_2
- VAL_3
default: VAL_2
TestModelWithEnumDefault:
type: object
required:
- test_enum
properties:
test_enum_common_prefix:
$ref: "#/components/schemas/EnumWithCommonPrefix"
test_enum:
$ref: "#/components/schemas/TestEnum"
test_string:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ docs/EnumClass.md
docs/EnumString1.md
docs/EnumString2.md
docs/EnumTest.md
docs/EnumWithCommonPrefix.md
docs/FakeApi.md
docs/FakeClassnameTags123Api.md
docs/Feeding.md
Expand Down Expand Up @@ -169,6 +170,7 @@ petstore_api/models/enum_class.py
petstore_api/models/enum_string1.py
petstore_api/models/enum_string2.py
petstore_api/models/enum_test.py
petstore_api/models/enum_with_common_prefix.py
petstore_api/models/feeding.py
petstore_api/models/file.py
petstore_api/models/file_schema_test_class.py
Expand Down
1 change: 1 addition & 0 deletions samples/openapi3/client/petstore/python-aiohttp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Class | Method | HTTP request | Description
- [EnumString1](docs/EnumString1.md)
- [EnumString2](docs/EnumString2.md)
- [EnumTest](docs/EnumTest.md)
- [EnumWithCommonPrefix](docs/EnumWithCommonPrefix.md)
- [Feeding](docs/Feeding.md)
- [File](docs/File.md)
- [FileSchemaTestClass](docs/FileSchemaTestClass.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EnumWithCommonPrefix


## Enum

* `VAL_1` (value: `'VAL_1'`)

* `VAL_2` (value: `'VAL_2'`)

* `VAL_3` (value: `'VAL_3'`)

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**test_enum_common_prefix** | [**EnumWithCommonPrefix**](EnumWithCommonPrefix.md) | | [optional] [default to EnumWithCommonPrefix.VAL_2]
**test_enum** | [**TestEnum**](TestEnum.md) | |
**test_string** | **str** | | [optional]
**test_enum_with_default** | [**TestEnumWithDefault**](TestEnumWithDefault.md) | | [optional] [default to TestEnumWithDefault.ZWEI]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
from petstore_api.models.enum_string1 import EnumString1
from petstore_api.models.enum_string2 import EnumString2
from petstore_api.models.enum_test import EnumTest
from petstore_api.models.enum_with_common_prefix import EnumWithCommonPrefix
from petstore_api.models.feeding import Feeding
from petstore_api.models.file import File
from petstore_api.models.file_schema_test_class import FileSchemaTestClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from petstore_api.models.enum_string1 import EnumString1
from petstore_api.models.enum_string2 import EnumString2
from petstore_api.models.enum_test import EnumTest
from petstore_api.models.enum_with_common_prefix import EnumWithCommonPrefix
from petstore_api.models.feeding import Feeding
from petstore_api.models.file import File
from petstore_api.models.file_schema_test_class import FileSchemaTestClass
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# coding: utf-8

"""
OpenAPI Petstore

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\

The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501


from __future__ import annotations
import json
from enum import Enum
from typing_extensions import Self


class EnumWithCommonPrefix(str, Enum):
"""
EnumWithCommonPrefix
"""

"""
allowed enum values
"""
VAL_1 = 'VAL_1'
VAL_2 = 'VAL_2'
VAL_3 = 'VAL_3'

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


Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from pydantic import BaseModel, ConfigDict, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from petstore_api.models.enum_with_common_prefix import EnumWithCommonPrefix
from petstore_api.models.test_enum import TestEnum
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
from typing import Optional, Set
Expand All @@ -28,12 +29,13 @@ class TestModelWithEnumDefault(BaseModel):
"""
TestModelWithEnumDefault
""" # noqa: E501
test_enum_common_prefix: Optional[EnumWithCommonPrefix] = EnumWithCommonPrefix.VAL_2
test_enum: TestEnum
test_string: Optional[StrictStr] = None
test_enum_with_default: Optional[TestEnumWithDefault] = TestEnumWithDefault.ZWEI
test_string_with_default: Optional[StrictStr] = 'ahoy matey'
test_inline_defined_enum_with_default: Optional[StrictStr] = 'B'
__properties: ClassVar[List[str]] = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"]
__properties: ClassVar[List[str]] = ["test_enum_common_prefix", "test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"]

@field_validator('test_inline_defined_enum_with_default')
def test_inline_defined_enum_with_default_validate_enum(cls, value):
Expand Down Expand Up @@ -96,6 +98,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
return cls.model_validate(obj)

_obj = cls.model_validate({
"test_enum_common_prefix": obj.get("test_enum_common_prefix") if obj.get("test_enum_common_prefix") is not None else EnumWithCommonPrefix.VAL_2,
"test_enum": obj.get("test_enum"),
"test_string": obj.get("test_string"),
"test_enum_with_default": obj.get("test_enum_with_default") if obj.get("test_enum_with_default") is not None else TestEnumWithDefault.ZWEI,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# coding: utf-8

"""
OpenAPI Petstore

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\

The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501


import unittest

from petstore_api.models.enum_with_common_prefix import EnumWithCommonPrefix

class TestEnumWithCommonPrefix(unittest.TestCase):
"""EnumWithCommonPrefix unit test stubs"""

def setUp(self):
pass

def tearDown(self):
pass

def testEnumWithCommonPrefix(self):
"""Test EnumWithCommonPrefix"""
# inst = EnumWithCommonPrefix()

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ docs/EnumClass.md
docs/EnumString1.md
docs/EnumString2.md
docs/EnumTest.md
docs/EnumWithCommonPrefix.md
docs/FakeApi.md
docs/FakeClassnameTags123Api.md
docs/Feeding.md
Expand Down Expand Up @@ -170,6 +171,7 @@ petstore_api/models/enum_class.py
petstore_api/models/enum_string1.py
petstore_api/models/enum_string2.py
petstore_api/models/enum_test.py
petstore_api/models/enum_with_common_prefix.py
petstore_api/models/feeding.py
petstore_api/models/field.py
petstore_api/models/file.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ Class | Method | HTTP request | Description
- [EnumString1](docs/EnumString1.md)
- [EnumString2](docs/EnumString2.md)
- [EnumTest](docs/EnumTest.md)
- [EnumWithCommonPrefix](docs/EnumWithCommonPrefix.md)
- [Feeding](docs/Feeding.md)
- [Field](docs/Field.md)
- [File](docs/File.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EnumWithCommonPrefix


## Enum

* `VAL_1` (value: `'VAL_1'`)

* `VAL_2` (value: `'VAL_2'`)

* `VAL_3` (value: `'VAL_3'`)

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**test_enum_common_prefix** | [**EnumWithCommonPrefix**](EnumWithCommonPrefix.md) | | [optional]
**test_enum** | [**TestEnum**](TestEnum.md) | |
**test_string** | **str** | | [optional]
**test_enum_with_default** | [**TestEnumWithDefault**](TestEnumWithDefault.md) | | [optional]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
from petstore_api.models.enum_string1 import EnumString1
from petstore_api.models.enum_string2 import EnumString2
from petstore_api.models.enum_test import EnumTest
from petstore_api.models.enum_with_common_prefix import EnumWithCommonPrefix
from petstore_api.models.feeding import Feeding
from petstore_api.models.field import Field
from petstore_api.models.file import File
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
from petstore_api.models.enum_string1 import EnumString1
from petstore_api.models.enum_string2 import EnumString2
from petstore_api.models.enum_test import EnumTest
from petstore_api.models.enum_with_common_prefix import EnumWithCommonPrefix
from petstore_api.models.feeding import Feeding
from petstore_api.models.field import Field
from petstore_api.models.file import File
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# coding: utf-8

"""
OpenAPI Petstore

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\

The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501


import json
import pprint
import re # noqa: F401
from aenum import Enum, no_arg





class EnumWithCommonPrefix(str, Enum):
"""
EnumWithCommonPrefix
"""

"""
allowed enum values
"""
VAL_1 = 'VAL_1'
VAL_2 = 'VAL_2'
VAL_3 = 'VAL_3'

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


Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@

from typing import Optional
from pydantic import BaseModel, Field, StrictStr, validator
from petstore_api.models.enum_with_common_prefix import EnumWithCommonPrefix
from petstore_api.models.test_enum import TestEnum
from petstore_api.models.test_enum_with_default import TestEnumWithDefault

class TestModelWithEnumDefault(BaseModel):
"""
TestModelWithEnumDefault
"""
test_enum_common_prefix: Optional[EnumWithCommonPrefix] = None
test_enum: TestEnum = Field(...)
test_string: Optional[StrictStr] = None
test_enum_with_default: Optional[TestEnumWithDefault] = None
test_string_with_default: Optional[StrictStr] = 'ahoy matey'
test_inline_defined_enum_with_default: Optional[StrictStr] = 'B'
__properties = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"]
__properties = ["test_enum_common_prefix", "test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"]

@validator('test_inline_defined_enum_with_default')
def test_inline_defined_enum_with_default_validate_enum(cls, value):
Expand Down Expand Up @@ -80,6 +82,7 @@ def from_dict(cls, obj: dict) -> TestModelWithEnumDefault:
return TestModelWithEnumDefault.parse_obj(obj)

_obj = TestModelWithEnumDefault.parse_obj({
"test_enum_common_prefix": obj.get("test_enum_common_prefix"),
"test_enum": obj.get("test_enum"),
"test_string": obj.get("test_string"),
"test_enum_with_default": obj.get("test_enum_with_default"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# coding: utf-8

"""
OpenAPI Petstore

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\

The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501


import unittest
import datetime

from petstore_api.models.enum_with_common_prefix import EnumWithCommonPrefix # noqa: E501

class TestEnumWithCommonPrefix(unittest.TestCase):
"""EnumWithCommonPrefix unit test stubs"""

def setUp(self):
pass

def tearDown(self):
pass

def testEnumWithCommonPrefix(self):
"""Test EnumWithCommonPrefix"""
# inst = EnumWithCommonPrefix()

if __name__ == '__main__':
unittest.main()
Loading