-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Python] each Configuration instance now has its own dicts #4485
[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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Thanks for the quick fix (:
import petstore_api | ||
|
||
|
||
class TestConfiguration(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Thanks for fixing this! 😃🚀 |
@spacether thanks for the PR, which has been included in the v4.2.2 release: https://twitter.com/oas_generator/status/1201432648544972800 |
This is a breaking change. Some libraries use the feature of creating default configuration and this PR removed it. Method |
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. |
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. |
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.sh
if 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)