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
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
when generating modles fo one-of/any-of of multiple string, a intermediate models for pydantic is generated,
which ignores patterns and passes/fails in a confusing manner
my recommendation for openapi-codegen would be to create type aliases for constrainted strings
(using either type statements or the runtime backport for them
The text was updated successfully, but these errors were encountered:
>>> import oapi_codegen_condused_values.models
>>> oapi_codegen_condused_values.models.PassString.from_dict({"mangled_string_one": "here"})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "...openapi-codegen-show-issues/oapi_codegen_condused_values/models/pass_string.py", line 92, in from_dict
"mangled_string_one": PassStringMangledStringOne.from_dict(obj["mangled_string_one"]) if obj.get("mangled_string_one") is not None else None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../oapi_codegen_condused_values/models/pass_string_mangled_string_one.py", line 82, in from_dict
return cls.from_json(json.dumps(obj))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../oapi_codegen_condused_values/models/pass_string_mangled_string_one.py", line 115, in from_json
raise ValueError("No match found when deserializing the JSON string into PassStringMangledStringOne with oneOf schemas: str. Details: " + ", ".join(error_messages))
ValueError: No match found when deserializing the JSON string into PassStringMangledStringOne with oneOf schemas: str. Details: 1 validation error for PassStringMangledStringOne
actual_instance
Value error, Multiple matches found when setting `actual_instance` in PassStringMangledStringOne with oneOf schemas: str. Details: [type=value_error, input_value='here', input_type=str]
For further information visit https://errors.pydantic.dev/2.7/v/value_error, 1 validation error for PassStringMangledStringOne
actual_instance
Value error, Multiple matches found when setting `actual_instance` in PassStringMangledStringOne with oneOf schemas: str. Details: [type=value_error, input_value='here', input_type=str]
For further information visit https://errors.pydantic.dev/2.7/v/value_error
>>>
Bug Report Checklist
Description
when generating modles fo one-of/any-of of multiple string, a intermediate models for pydantic is generated,
which ignores patterns and passes/fails in a confusing manner
https://github.com/RonnyPfannschmidt-RedHat/openapi-codegen-show-issues/blob/9659d501374b493fe1dd43aa18c48ba2c3b924d0/oapi_codegen_broken_string/models/pass_string_mangled_string_any.py#L29-L115
https://github.com/RonnyPfannschmidt-RedHat/openapi-codegen-show-issues/blob/9659d501374b493fe1dd43aa18c48ba2c3b924d0/oapi_codegen_broken_string/models/pass_string_mangled_string_one.py#L27C1-L118C1
openapi-generator version
7.6.0
OpenAPI declaration file content or url
https://github.com/RonnyPfannschmidt-RedHat/openapi-codegen-show-issues/blob/9659d501374b493fe1dd43aa18c48ba2c3b924d0/openapi/openapi.BrokenString.yaml#L1-L42
Generation Details
Suggest a fix
a starting point would be to re-attach the patterns to the validation
optional strings with a string constraints should be used
additionally the nesting is quite a pain wrt choice of object models, i'd strongly prefer if no indirection models where introduced
https://github.com/RonnyPfannschmidt-RedHat/openapi-codegen-show-issues/blob/9659d501374b493fe1dd43aa18c48ba2c3b924d0/manual_pydantic_broken_string.py is a minimal version of using pydantic validators to pass over those values
my recommendation for openapi-codegen would be to create type aliases for constrainted strings
(using either type statements or the runtime backport for them
The text was updated successfully, but these errors were encountered: