* I feel the issue is due to the creation of self._var_name_to_model_instances while doing the deserialization of the data.
Earlier the Python SDK code was using get_var_name_to_model_instances function which was adding var name to model instances that contain it. So <class 'openapi_client.model.stream_options_all_of'> will not part of mapping in self._var_name_to_model_instances for variable name stream_options.
Now with the latest Python SDK code following is the way through which var_name_to_model_instances is created:
for prop_name in model_args:
if prop_name not in discarded_args:
var_name_to_model_instances[prop_name] = [self] + composed_instances
Now as we can see that the var_name_to_model_instances is populated with self and composed_instance which will also contain stream_options_all_of as a composed instance and there will be no check that if stream_options is present in composed_instances or not.
As there is no attribute_mapping found for stream_options in stream_options_all_of, the type for stream_options will be treated as dict for mapping stream_options_all_of as mentioned by @Chekov2k.
So what I suggest is the following code:
for prop_name in model_args:
if prop_name not in discarded_args:
var_name_to_model_instances[prop_name] = [self] + list(
filter(
lambda x: prop_name in x.openapi_types, composed_instances))
This way we can check if the property name is present in that composed instance or not. If it's okay for @spacether I can raise a PR for this.
* [get_item_all_of_bug]
Added samples, test cases to validate all_of schema.
* [getiem_all_of_bug]
Updated docs and samples.
* [getiem_all_of_bug]
Updated test cases, docs and samples.
* fix#11958 [BUG] python generates wrong model name and model file name
Modify AbstractPythonCodegen.toModelName just like AbstractJavaCodegen.toModelName
* add unit test
* update samples and docs
by
./bin/generate-samples.sh
./bin/utils/export_docs_generators.sh
* fix AbstractPythonCodegen#toModelName logic, remove underscore
* update samples and docs
by
./bin/generate-samples.sh
./bin/utils/export_docs_generators.sh
* [req_vars_changes]
* Added new schema to generate samples to test the issue mentioned in the PR.
* Changed the variable name from setRequiredVars to initRequiredVars
* Added initRequiredVars as a generator additional property
* Regenerating the samples after rebasing the code with master branch
* Changed the description of additional property
* LDS-2166 : add request auth to api client and api call
Can now overwrite request auth by request
Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten
* LDS-2166 : Add samples
Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten
* LDS-2166 : fix test
Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten
* LDS-2166 : Fixing test in python_disallowAdditionalPropertiesIfNotPresent
Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten
* LDS-2166 : add removed line break
Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten
* LDS-2166 : add name for _request_auth params
Add None when _content_type is not set
Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten
* LDS-2166 : add tabulation
Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten
* LDS-2166 : fix missing values
Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten
* LDS-2166 : generate sample
Add _request_auth in sample
Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten
* Request auth can now use multiple auth
Request auth is now a list of dict
Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten
* Add request_auths in test
Envoyé depuis mon iPhone.
P.S. : Ce commit est certifié sans gluten
Co-authored-by: Géry THRASIBULE <g.thrasibule@lecomptoirdespharmacies.fr>
* add no_proxy support to python client
* add unittest for no_proxy supporting, python client
* update samples for no_proxy supporting, python client
* fix input parameter in samples/openapi3/.../tests_manual/test_extra_pool_config_options.py
* re-implement no_proxy support to python client according to PR conversation #10648
* re-update samples for no_proxy supporting, python client
* Updated template so that generated code now renders docstrings and function parameters nicely in IDE.
Endpoints are still accessible in generated code, mainly to satisfy some test cases.
* fixed manual tests
* adding a test for issues 10083
* commiting the generated files
* fix for the setattr issue
* commit generated files
Co-authored-by: Aanisha Mishra <aanisha.mishra05@gmail.com>
* fixes a breakage while deserializing the read-only attributes
* updating generated samples
* taking care of the PR comments
* updating samples
* protect against cases where _spec_property_naming may not be present
* updating samples
* adding tests for this issue
* other generated files
* taking care of the comments
* updating the generated samples
Co-authored-by: Aanisha Mishra <aanisha.mishra05@gmail.com>
* [BUG][PYTHON] Do not set Content-Type for GET, HEAD or DELETE requests
The Python generator no longer sets a default `Content-Type` of
`application/json` for `GET`, `HEAD` and `DELETE` requests.
Having the `Content-Type` set for these requests was causing issues with
other tools which insist that GET, HEAD and DELETE requests do not have
a Content-Type (as per the OpenAPI 3 specification).
An example of the problem that this commit fixes is when using
[Prism][1] as a [validation proxy][2].
[Prism rejects any GET request that has a Content-Type][3].
Here is [an example of the problem manifesting itself][4].
To validate the fix in this commit:
1. Start with any OpenAPI3 spec e.g. the Petstore example at
https://editor.swagger.io/
2. Generate Python client code for the spec
3. Look at the generated `rest.py` e.g. in the [standard sample in this
repo][5] and see that the `Content-Type` defaults to `application/json`
for all HTTP methods (including `GET`, `HEAD` and `DELETE`), rather than
there being no `Content-Type` for `GET`, `HEAD` and `DELETE`.
Fixes#9831
[1]: https://github.com/stoplightio/prism
[2]: https://meta.stoplight.io/docs/prism/docs/guides/03-validation-proxy.md
[3]: https://github.com/stoplightio/prism/issues/1408#issuecomment-690948020
[4]: https://github.com/agilepathway/gauge-openapi-example/pull/28/checks?check_run_id=2888606052#step:13:18
[5]: 969cea8ce1/samples/openapi3/client/petstore/python/petstore_api/rest.py (L141)
* update samples
* Fix Python DELETE bug introduced in earlier commit
The earlier commit 9dfe1f6 introduced a bug for `DELETE` requests on the
standard Python generator. This commit fixes that bug and also includes
the updated samples.
Co-authored-by: William Cheng <wing328hk@gmail.com>
* [python][client] allow passing floats for _request_timeout
While several method docstrings suggested that you could pass floats for
_request_timeout and the underlying urllib3.Timeout can deal with them,
the code only allowed integer values so far when passed as a single
number.
* [python][samples] update with fix for _request_timeout type
* fix by mapping outside of class
* tests
* regeneration and tests
* server
* INDENT
* a
* enable mapping
* Revert "server"
This reverts commit 6fc9712fb550d258d0332df243ea5080565c6770.
* Samples regenerated
Co-authored-by: Justin Black <justin.a.black@gmail.com>
* Fixes additionalProperties values for models, updates docs, adds tag test of it, fixes frit and gmfruit tests
* Moves this.setDisallowAdditionalPropertiesIfNotPresent higher
* Makes setting additional_properties_model_instances contingent on the presence of addprosp in schema, updates sample spec composed schemas to remove addprops False form two
* Fixes oneOf anyOf allOf instantiation logic
* Removes Address from Cat definition
* Adds required vars for apple and banana, removes required vars from composed schema init sig
* Updates composed schema vars to be set on self and all composed instances
* Removes get_unused_args, get_var_name_to_model_instances, and get_additional_properties_model_instances
* Fixes fruit + deserilization tests, creates ComposedSchemaWithPropsAndNoAddProps
* Fixes FruitReq tests
* Fixes GmFruit tests
* Fixes discard_unknown_keys tests
* Samples updated
* Removes additionalproperties False in Child
* Samples updated
* Improves handling of v2 and v3 specs for isFreeFormObject, v2 sample spec updated with link to bug
* Adds cli option disallowAdditionalPropertiesIfNotPresent to python
* Adds getAdditionalProperties method so the value for addProps will be correct
* Reverts file
* Reverts file
* Updates python doc
* Reverted anytype_3 definition
* Updates test_deserialize_lizard
* Updates test_deserialize_dict_str_dog
* Updates testDog
* Updates testChild
* Adds v2 python_composition sample
* Adds needed files for python testing
* Adds existing tests into the new python sample
* Fixes test_dog
* Removes addProps false form Dog
* Fixes testChild
* Updates how additionalProperties are set
* Fixes empty_map type
* Type generation fixed for v2 and v3 specs
* Refactors getTypeString, updates artifactids in pom.xml files
* Adds new python sample to CI testing I think
* Fixes artifactId collision, regenrates docs
* Removes nulltype from python, updates samples
* Removes nulltype from the python requirements
* Removes nulltype import in models, moves requiredVars to optionalVars when approprieate