Uh oh!
There was an error while loading. Please reload this page.
[Python] each Configuration instance now has its own dicts - #4485
Conversation
…ulti-level-model-hierarchy * origin/master: minor fix to CI failure feat(dart-dio): correctly handle Map<String, Object>, List<Object> using JsonObject (OpenAPITools#4401) [OCAML] Fixes cloud.drone.io ocaml-test (OpenAPITools#4501) [elm] Add support for oneOf (OpenAPITools#4434) [BUG] [Java] Client resttemplate and webclient. Form Params are badly added when they are lists (OpenAPITools#4461) fix: prevent ClassCastException when handling options of (issue OpenAPITools#4468) (OpenAPITools#4495) Fixes Python client Configuration class so each instance uses its own dicts (OpenAPITools#4485)
| import petstore_api | ||
| class TestConfiguration(unittest.TestCase): |
TimoMorris
commented
Nov 17, 2019
Thanks for fixing this! 😃🚀 |
wing328
commented
Dec 2, 2019
@spacether thanks for the PR, which has been included in the v4.2.2 release: https://twitter.com/oas_generator/status/1201432648544972800 |
tomplus
commented
Feb 11, 2020
This is a breaking change. Some libraries use the feature of creating default configuration and this PR removed it. Method |
spacether
commented
Feb 11, 2020
Sorry that we broke this functionality. We look forward to your PR.
|
@tomplus Sorry to hear we've caused you difficulties 😞 FWIW I did quite a detailed write-up of the issues I found with the way the behavior around default configurations when I raised issue #3577 (essentially the same as this issue as this one), which you might find helpful to refer to. Essentially, it wasn't only caching a copy of the first configuration instantiated to use as a default, but it would then always return this default, even if It seemed to me the expected behavior would be to (at most) cache the first configuration as a default and return this if you called I imagine it would be relatively straightforward to re-implement a And I'd agree with @spacether's suggestions that the user implementing the defaulting behaviour in their own code seems better. |
tomplus
commented
Feb 11, 2020
Thanks for the discussion. I know that it can be implemented in many ways but for me previous implementation was very handy (apart from bugs which were found). I have one server with many API exposed. I was able to create a well-prepared default configuration on startup and then used it without worrying about it. I think the static method set_default() doesn’t break the principle “explicit is better than implicit” because I have to explicitly set configuration as default configuration. I'm sending a PR soon. |
tomplus
commented
Feb 14, 2020
Here is my PR #5315, Thanks for reviewing. |
Per this issue: #4389
The dictionaries used in Configuration instances are shared across instances.
This is not the intended function.
Each instance should use its own unique dict to store api_key and api_key_prefix
This PR makes that update and adds a test at samples/client/petstore/python/tests/test_configuration.py for verification
Related issue that may be closed by this PR:
PR checklist
./bin/(or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.shif updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).master,4.3.x,5.0.x. Default:master.Python committee
@taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) @slash-arun (2019/11)