Skip to content

Commit ef61753

Browse files
committed
apply same fix to python pydantic v1
1 parent 3970889 commit ef61753

5 files changed

Lines changed: 18 additions & 16 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,8 @@ public void setMapNumberTo(String mapNumberTo) {
15931593
}
15941594

15951595
public String toEnumVariableName(String name, String datatype) {
1596+
name = name.replace(".", "_DOT_");
1597+
15961598
if ("int".equals(datatype)) {
15971599
return "NUMBER_" + name.replace("-", "MINUS_");
15981600
}

samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Type.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
## Enum
55

6-
* `NUMBER_2.0` (value: `2.0`)
6+
* `NUMBER_2_DOT_0` (value: `2.0`)
77

8-
* `NUMBER_1.0` (value: `1.0`)
8+
* `NUMBER_1_DOT_0` (value: `1.0`)
99

10-
* `NUMBER_0.5` (value: `0.5`)
10+
* `NUMBER_0_DOT_5` (value: `0.5`)
1111

12-
* `NUMBER_0.25` (value: `0.25`)
12+
* `NUMBER_0_DOT_25` (value: `0.25`)
1313

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

samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/type.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class Type(int, Enum):
2929
"""
3030
allowed enum values
3131
"""
32-
NUMBER_2.0 = 2.0
33-
NUMBER_1.0 = 1.0
34-
NUMBER_0.5 = 0.5
35-
NUMBER_0.25 = 0.25
32+
NUMBER_2_DOT_0 = 2.0
33+
NUMBER_1_DOT_0 = 1.0
34+
NUMBER_0_DOT_5 = 0.5
35+
NUMBER_0_DOT_25 = 0.25
3636

3737
@classmethod
3838
def from_json(cls, json_str: str) -> Type:

samples/openapi3/client/petstore/python-pydantic-v1/docs/Type.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
## Enum
55

6-
* `NUMBER_2.0` (value: `2.0`)
6+
* `NUMBER_2_DOT_0` (value: `2.0`)
77

8-
* `NUMBER_1.0` (value: `1.0`)
8+
* `NUMBER_1_DOT_0` (value: `1.0`)
99

10-
* `NUMBER_0.5` (value: `0.5`)
10+
* `NUMBER_0_DOT_5` (value: `0.5`)
1111

12-
* `NUMBER_0.25` (value: `0.25`)
12+
* `NUMBER_0_DOT_25` (value: `0.25`)
1313

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

samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/type.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class Type(int, Enum):
2929
"""
3030
allowed enum values
3131
"""
32-
NUMBER_2.0 = 2.0
33-
NUMBER_1.0 = 1.0
34-
NUMBER_0.5 = 0.5
35-
NUMBER_0.25 = 0.25
32+
NUMBER_2_DOT_0 = 2.0
33+
NUMBER_1_DOT_0 = 1.0
34+
NUMBER_0_DOT_5 = 0.5
35+
NUMBER_0_DOT_25 = 0.25
3636

3737
@classmethod
3838
def from_json(cls, json_str: str) -> Type:

0 commit comments

Comments
 (0)