29 Commits

Author SHA1 Message Date
Yousef Haggy
7a23ac7615
[Python] Bug Fix - model_generic templates to have valid imports for polymorphism (#20273)
* fix model_generic python templates to have valid imports for polymorphism

* update samples

* update samples

---------

Co-authored-by: yugi <yugi-big@proton.me>
2025-01-09 11:40:47 +08:00
Chirag Jain
67af02ccc8
python-pydantic-v1: Keep trailing commas for enum validation tuples (#19985)
* python-pydantic-v1: Keep trailing commas for tuples when enum has just single member

* Update samples

* Add test for single member enums

* Refactor test name
2024-11-02 15:26:19 +08:00
Rory Schadler
8171648eb4
fix(python,asyncio): multipart form data serialization (#19302)
* fix: object serialization for multipart requests

This PR is essentially
<https://github.com/OpenAPITools/openapi-generator/pull/18140> but for
the asyncio client.

* fix: int serialization for multipart requests

urllib3 handles serializing ints in post params (ref 1), while asyncio
explicitly does not (ref 2).

ref 1: <9316764e90/src/urllib3/filepost.py (L75-L76)>
ref 2: <https://github.com/aio-libs/aiohttp/issues/920>

* test: new fake multipart endpoint with files and body

* test: regression test for stringified body params

* fix: mypy tweak

* fix: FILES regeneration

* feat: object, int serialization for multipart reqs

Extends previous commits (and #18140) to cover the python-pydantic-v1
client as well.

* fix: use async with in test

* test: regression test for pydantic-v1-aiohttp

* test: add regression test to pydantic-v1

Also brings the second test in line with the first, patching
`urllib3.PoolManager.urlopen`
2024-09-09 17:43:25 +08:00
VelorumS
f082a35d2e
[Python] fix object arrays giving mypy error "Incompatible types in assignment" in to_dict() (#19223)
* [python] mypy fix for multiple arrays of objects

* [python] mypy test for multiple arrays of objects
2024-07-29 16:34:27 +08:00
William Cheng
0cc9644120
Add enum default value tests to python clients (#18883)
* add enum default value tests to python clients

* add new files
2024-06-08 17:34:57 +08:00
Lars van Leeuwen
8783ad8a18
[Python] List enum members in docs (#18804)
* List enum values in docs

* Remove newline

* Remove another newline

* Generate samples
2024-06-01 17:00:11 +08:00
0xMattijs
365fcd3fb4
Fix the post processing of enums in the Python generator, such that it uses the proper variable namesfrom x-enum-varnames (#18566)
Remove sample
2024-05-12 00:40:06 +08:00
Zishun (Zack) Wei
81fab15a33
[PYTHON] Fix for failing to lookup discriminator value using AllOf and discriminator (#18498)
* fix issue 18495

* add tests and update samples

* update samples
2024-04-30 14:21:20 +08:00
Kathryn DiPippo
0b3e6edb98
[python] Update docs/ Markdown files for Classes to fix _form_ typo and correct casing for class name when calling from_dict() (#18359)
* Update Python mustache templates to fix _form_ typo and correct casing for class name when calling from_dict()

* Results of 'build the project' checklist step
2024-04-12 12:29:20 +08:00
BaptisteSaves
6bcc28d06e
Python: Correctly serialize enum with its value (#18327) (#18328) 2024-04-10 21:12:37 +08:00
Zishun (Zack) Wei
453facc81c
Fix 18271: Circular imports on AllOf generation with REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=True (#18272)
* fix issue 18271

* the same update for python-pydantic-v1

* add test

* update samples

* update samples

* put properties under allOf for python client tests

* update samples

* add a test in test model
2024-04-08 19:01:01 +08:00
William Cheng
2a39b29684
[python] Add field as a reserved word (#18279)
* add field as a reserved word

* remove tabs

* update
2024-04-03 16:43:51 +08:00
ふぁ
9acd620bbb
[Python] Add test object serialization for multipart requests (#18156)
* [Python] add test object serialization for multipart requests #18140

* [python] update samples

* [python] update samples
2024-03-24 09:37:44 +08:00
ふぁ
e39b99051c
[python] add test Missing the important statement for Datetime in Python binding generation (#18175)
* [python] add test on datetime response import

* [python] update sample

* [python] update sample
2024-03-21 15:40:33 +08:00
ふぁ
678db1e4af
[python] json like str response (#18069)
* [python] json like str response

* [python] fix response deserialize

* [python] update sample

* [python] fix echo_api test quotes
2024-03-11 20:27:26 +08:00
ふぁ
ad08581f16
[python] Fix Circular imports on inherited discriminators. (#17886)
* [python] add inheritance discriminators test #16808

* [python] update samples

* [python] fix assert in test

* [python] fix inheritance discriminators circular import

* [python] update samples

* [python] undo type changes related to discriminator

* [python] remove extraneous processing

* [python-pydantic-v1] fix inheritance discriminators circular import

* [python] remove type ignore comment

* [python] update samples

* [python] fix avoid the empty line break

* [python] update samples
2024-02-20 12:17:32 +08:00
Jonathan Klaassen
6bcf8cd332
Fix Python codegen in specific additionalProperties case. (#17659)
* Fix Python codegen is specific additionalProperties case.

* Add generated test files.

* Apply fix to AbstractPythonPydanticV1Codegen.java.
2024-02-05 22:17:14 +08:00
William Cheng
c9204c4330
Update model_generic.mustache, tuple notation breaks when there is only one element in the tuple (#17749)
* Update model_generic.mustache, tuple notation breaks when there is only one element in the tuple

In this excerpt of the mustache template, the matching behaviour is bugged when there is only one element in the tuple notation. A single string with the tuple notation, e.g., `("string")`, will result in a string, and when values are compared with the string, it will do a `contains` match instead of an exact match, which is unintended behaviour.

* Update with samples, step 3

* Add test spec and regenerate samples

* Update samples

* Update spec and samples

* update samples

---------

Co-authored-by: Edmund Loo <edmundloo@users.noreply.github.com>
Co-authored-by: Edmund Loo <github.yn0u9@simplelogin.com>
2024-01-31 11:29:15 +08:00
martin-mfg
9afea50cab
use map/array model class only if it is generated (#17612)
* fix

* tests

* generate samples

* refactor
2024-01-29 21:35:21 +08:00
Huan-Cheng Chang
968c6dc418
[Python] Handle nullable list items (#17594)
* fix nullable elements

* update type info in docs

* update examples
2024-01-13 11:29:22 +08:00
martin-mfg
64f2cad9e8
fix #17258 - use model class only if it is generated (#17490)
* fix  #16797 and #15796 spring child constructor missing parent params

* root cause and update the DefaultCodegen.java to add missing property when with multi inheritance

* rollback SpringCodegen.java

* update samples

* rollback with master cause #16992 fixed this issue too

* still using orignal design

* catchup master

* catchup master

* catchup master

* fix

* add tests

---------

Co-authored-by: dabdirb <dabdirb@gmail.com>
2024-01-05 10:30:28 +08:00
William Cheng
a62132ecd9
fix exception in request body with enum ref (#17438) 2023-12-21 15:22:28 +08:00
Robert Schweizer
75ff110449
[python] Some cleanup of samples folder (#17127)
* Delete sample folders of discontinued clients

* Remove duplicate python-flask server sample

The python-flask sample actually lives in samples/server/petstore/python-flask.

* Move hand-written test to "tests" folder

Now, "test" only contains generated stubs and all hand-written tests are in "tests".

* Delete left-over files in Python samples

These are not created by the generators (anymore) and not hand-written
for testing.

* Regenerate test file to fix import error
2023-11-19 14:43:34 +08:00
Robert Schweizer
e47e7041f7
[python][Feat] Deserialize error responses (#17038)
* refactor: Clean up _response_types_map formatting

It matches black's behavior of having trailing commas now.

* test: Add test to reproduce #16967

* fix: deserialize responses even if no returnType

Closes #16967

* refactor: Simplify ApiException subclasses

* refactor: Move exception subtype choice to ApiException

* feat: Deserialize error responses and add to exceptions

* test: Add for error responses with model
2023-11-16 00:37:04 +08:00
Robert Schweizer
f180aa0eec
[python] Fix unnamed dicts with additional properties (#16779)
* test: Add two extra models for testing

* Fix unnamed dicts with additional properties

Closes #16630
2023-10-11 13:55:53 +08:00
William Cheng
ce4b2fe7bd
[Python] add float to reserved word list (#16689)
* add float as reserved world

* clean up

* update samples

* Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java

Co-authored-by: Jonathan Ballet <jon@multani.info>

* update doc

* uncomment test

---------

Co-authored-by: Jonathan Ballet <jon@multani.info>
2023-10-01 20:41:54 +08:00
ふぁ
c6e9a4e1ae
[python] change Private attr to Class vars (#16687)
* [python] fix TypeError

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update Private model attributes to Class vars

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] rename the List of test cases to ListClass

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] rename the List of v1 test cases to ListClass

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] rename the List of v1-aiohttp test cases to ListClass

Signed-off-by: ふぁ <yuki@yuki0311.com>

* update samples

---------

Signed-off-by: ふぁ <yuki@yuki0311.com>
Co-authored-by: William Cheng <wing328hk@gmail.com>
2023-10-01 16:52:23 +08:00
Jonathan Ballet
04fa53b692
python: generate Pydantic v2 + typing complete code (#16624)
* python: improve type generation with more specific typing

* Annotate function parameters

* Remove unused imports

* remove unused files

* remove temporary hack

* remove lock file

* fix Annotated import

* support Python 3.7

* Regenerate code with typing-extensions

* Fix setup.py

* More Pydantic v2 compatibility

* depend on pydantic v2

* fix client_echo tests

* fix JSON serialization

* Fix references

* Skip circular dependency tests for now

* Temporarily hide the "float" property

The "float" property aliases the "float" type and completely breaks the
model: all the properties that were "float" now become the type of the
"float" property instead.

* Fix errors

* Import Literal from typing_extensions

* Fix GitHub Action workflows

* Fix Python 3.7 failure

* Fix quotes

* Apply suggestions from code review

* Fix tests

* split model imports from other modules imports

* fix workflow

* Comment the array unique items convertion, remove set translation

* Replace alias usage
2023-09-28 19:13:14 +08:00
Jonathan Ballet
3b95f701e5
python: copy the current Python generator into a "pydantic v1" generator (#16656)
* Copy the current Python generator into a "pydantic v1" generator

This generator will be deprecated over time and the normal generator will
focus on Pydantic v2.

* add missing doc
2023-09-25 12:13:24 +08:00