mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-02 21:50:55 +00:00
Replace periods with '_DOT_' in Python enum member names (#21372)
This is relevant for enums whose values are floats since without this step the enum is syntactically invalid. See: https://github.com/OpenAPITools/openapi-generator/issues/21322
This commit is contained in:
parent
b57c23b121
commit
d88d588665
@ -1061,6 +1061,8 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
public String toEnumVariableName(String name, String datatype) {
|
||||
name = name.replace(".", "_DOT_");
|
||||
|
||||
if ("int".equals(datatype)) {
|
||||
return "NUMBER_" + name.replace("-", "MINUS_");
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: Sample API
|
||||
description: API description in Markdown.
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/pony-sizes:
|
||||
get:
|
||||
summary: Returns all pony sizes.
|
||||
description: Optional extended description in Markdown.
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/PonySizes'
|
||||
components:
|
||||
schemas:
|
||||
PonySizes:
|
||||
type: object
|
||||
properties:
|
||||
type:
|
||||
$ref: '#/components/schemas/Type'
|
||||
Type:
|
||||
type: float
|
||||
enum:
|
||||
- 2.0
|
||||
- 1.0
|
||||
- 0.5
|
||||
- 0.25
|
Loading…
x
Reference in New Issue
Block a user