* 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
* fix-for-bug-16086
* add to_dict alternative
* fix assertEqual
* remove extra blank line + test_model Argument SecretStr set
* update samples / remove extra blank line
* restore sanitize test for serialization with different data types
* remove empty line in api_client.mustache
* remove 2nd empty line in api_client.mustache
* add initial openapi config and java generated files
* add java implementation for adding generator version
* regenerate sample client files
* remove tabs
* only show generated version if build info exists
* set build info for batch generation
* update generator doc for new global flag
* use existing property for generator version
* update templates to include generator version
* update templates for better generator version syntax
* revert undesired changes
* regenerate samples for openapi client
* update templates to correct formatting/newlines
* correct description text and add to usage doc
* add generator cli option for all codegen types
* use more concise version info; update existing codegens to support new prop
* correct wrong prop reference
* add initial test coverage for new prop
* update last (scala) templates with new prop
* update samples after upstream merge
* use consistent version output
* use better sample project id/name
* revert using option for generator version in templates
The EOL is missing so let's add it in order to comply with POSIX standard:
Line
> A sequence of zero or more non- <newline> characters plus a terminating <newline> character.
* 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>
* python: adjust basic typing information
This is an initial pass to fix and adjust the typing information for the
generated client. This is enough to have mypy runnning without complains
on all the (modern) generated clients (Pydantic v1 code is not checked
for instance)
mypy is also now run directly in the CI, so further changes will also be
checked and thus, will need to be compliant with good typing
information.
Note that this doesn't *fully* type all the code: mypy is not run in
"strict" mode and there are still many functions/methods/attributes
which are still not fully typed, but it's a first good step in that
direction.
* ApiResponse's raw_data can't be None
* Fix indentation
* Revert test changes
* run mypy on tests/ directory
* don't forcefully convert the client response headers to dict
* override petstore ApiResponse model
* adjust type of 'any/one_of_schemas' fields
In #16624, I introduced a new mechanism to record imports to other
modules, instead of having specialized datetime/typing/pydantic objects
to manage imports for these modules.
This change reuses the mechanism from #16624 and replace the specialized
import managers by the generic one. Unused imports from various
.mustache templates are also cleaned up.
* updating test to use the Java RESTEasy echo api client (#17367)
* regenerated samples
* set source and target to 1.8 to fix workflow failure, adapted parser
This was removed in #16802, but using a higher value than 1,
or at least making this configurable makes complete sense.
Without this, we get a lot of these log messages:
[ WARNING] Connection pool is full, discarding connection:
* 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
For model classes with model_something fields, pydantic raises a warning by default:
`Field "model_something" has conflict with protected namespace "model_".`.
These warnings make no sense here, because most users of the generator have established APIs
that they cannot change to conform to pydantic's safety rules.
Pydantic will raise an error if we ever conflict with a current attribute like `model_dump`.
* chore: add test to show python bool url params are not lower case
* fix: python parameters_to_url_query template to properly detect booleans
* fix: typo in test
* fix: typo in test
* chore: update test name to snake case and be more descriptive
* refactor: Use newlines in _with_http_info call
This prevents too-long lines and matches the style that
black would enforce.
* fix: Do not pydantic-validate function args twice
Closes#15757
* python: type generated client using Self
This doesn't offer a clear win but this helps for:
* Using modern types and making the typing intent clearer
* Decreasing the need for `from __future__ import annotations`, since a
class can now refer to itself without using its name
* Using more `cls` to automatically refer to the class, instead of
respecifying the class name every time
Self is available from Python 3.11 and is provided in typing_extensions
(since 4.0.0) as a fallback for older versions
See: https://peps.python.org/pep-0673/
See: https://github.com/python/typing_extensions/blob/main/CHANGELOG.md#added-in-version-400
* generate code
The aenum dependency didn't provide any specific improvements over the
stdlib's enum module.
aenum also doesn't provide typing information at the moment.
This removes one dependency and will help for completing the typing of
the generated client.
* In samples/openapi3/client/petstore/python, this reduces the mypy errors from 435 to 178 errors
* In samples/openapi3/client/petstore/python-aiohttp, this reduces the mypy errors from 381 to 124 errors
* In samples/client/echo_api/python, this reduces the mypy errors from 131 to 25 errors
* 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>