You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
Have you provided a full/minimal spec to reproduce the issue?
Have you validated the input using an OpenAPI validator (example)?
Have you tested with the latest master to confirm the issue still exists?
Have you searched for related issues/PRs?
What's the actual output vs expected output?
[Optional] Sponsorship to speed up the bug fix or feature request
Description
Invalid generated function names base on enum values beginning with a number like 2D_Object. This enum will be transformed to:
# coding: utf-8""" the test title The test REST API # noqa: E501 The version of the OpenAPI document: 1 Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator"""from __future__ importannotationsfromopenapi_client.shared_imports.schema_importsimport*# pyright: ignore [reportWildcardImportFromLibrary]classAnnotationTypeEnums:
@schemas.classpropertydef2D_OBJECT(cls) ->typing.Literal["2D_Object"]:
returnAnnotationType.validate("2D_Object")
@schemas.classpropertydef3D_OBJECT(cls) ->typing.Literal["3D_Object"]:
returnAnnotationType.validate("3D_Object")
@dataclasses.dataclass(frozen=True)classAnnotationType(
schemas.Schema
):
"""NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator Do not edit the class manually. """types: typing.FrozenSet[typing.Type] =frozenset({
str,
})
enum_value_to_name: typing.Mapping[typing.Union[int, float, str, schemas.Bool, None], str] =dataclasses.field(
default_factory=lambda: {
"2D_Object": "2D_OBJECT",
"3D_Object": "3D_OBJECT",
}
)
enums=AnnotationTypeEnums@typing.overload@classmethoddefvalidate(
cls,
arg: typing.Literal["2D_Object"],
configuration: typing.Optional[schema_configuration.SchemaConfiguration] =None
) ->typing.Literal["2D_Object"]: ...
@typing.overload@classmethoddefvalidate(
cls,
arg: typing.Literal["3D_Object"],
configuration: typing.Optional[schema_configuration.SchemaConfiguration] =None
) ->typing.Literal["3D_Object"]: ...
@typing.overload@classmethoddefvalidate(
cls,
arg: str,
configuration: typing.Optional[schema_configuration.SchemaConfiguration] =None
) ->typing.Literal["2D_Object","3D_Object",]: ...
@classmethoddefvalidate(
cls,
arg,
configuration: typing.Optional[schema_configuration.SchemaConfiguration] =None
) ->typing.Literal[
"2D_Object",
"3D_Object",
]:
validated_arg=super().validate_base(
arg,
configuration=configuration,
)
returntyping.cast(typing.Literal[
"2D_Object",
"3D_Object",
],
validated_arg
)
The resulting function name is not a valid Python name.
I know that this issue mention the same problem which is apparently fixed but it still not working in my case.
openapi-json-schema-generator version
Current master branch
OpenAPI declaration file content or url
openapi: 3.0.0components:
examples: {}headers: {}parameters: {}requestBodies: {}responses: {}schemas:
AnnotationType:
enum:
- 2D_Object
- 3D_Objecttype: stringinfo:
title: the test titleversion: '1'description: 'The test REST API'contact: {}paths:
'/example/get':
get:
operationId: GetExampleresponses:
'200':
description: Ok
Generation Details
I I build the corresponding .jar file based on the current master branch via the command mvn clean install and used the following command to generate the python client:
Bug Report Checklist
Description
Invalid generated function names base on enum values beginning with a number like
2D_Object
. This enum will be transformed to:The resulting function name is not a valid Python name.
I know that this issue mention the same problem which is apparently fixed but it still not working in my case.
openapi-json-schema-generator version
Current master branch
OpenAPI declaration file content or url
Generation Details
I I build the corresponding
.jar
file based on the current master branch via the commandmvn clean install
and used the following command to generate the python client:java -jar target/openapi-json-schema-generator-cli.jar generate -i /home/marcel/Documents/arbeit_projekte/openapi_generator_tests/openapi_reduced.yaml -g python -o /home/marcel/Documents/arbeit_projekte/openapi_generator_tests/reduced_spec --skip-validate-spec --additional-properties=generateAliasAsModel=true
Java version: 11.0.22
Apache Maven: 3.9.6
Steps to reproduce
yaml
file to generate the python clientAnnotationType
Related issues/PRs
#70
Suggest a fix
The text was updated successfully, but these errors were encountered: