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:
Peter Caisse 2025-06-04 03:18:58 -04:00 committed by GitHub
parent b57c23b121
commit d88d588665
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 0 deletions

View File

@ -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_");
}

View File

@ -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