Fix problem in sanitize_for_serialization for Python (pydantic type SecretStr ) BUG#16086 (2nd pull)#18023
Conversation
| # model definition for request. | ||
| obj_dict = obj.to_dict() | ||
| if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')): | ||
|
|
There was a problem hiding this comment.
can you please remove this extra blank line?
There was a problem hiding this comment.
can you please remove this extra blank line?
done
|
please also review the test failure when you've time: https://github.com/OpenAPITools/openapi-generator/actions/runs/8176114031/job/22463329272?pr=18023 |
Bug 16086
update samples / remove extra blank line
if complains: I set password as SecretStr: l = LoginTest(username="admin", password=SecretStr("testing09876")) |
| self.assertEqual(a.pattern_with_digits_and_delimiter, "image_123") | ||
|
|
||
| # test sanitize for serializaation with SecretStr (format: password) | ||
| self.assertEquals(petstore_api.ApiClient().sanitize_for_serialization(a), {'byte': b'string', 'date': '2013-09-17', 'number': 123.45, 'password': 'testing09876', 'pattern_with_digits_and_delimiter': 'image_123'}) |
There was a problem hiding this comment.
thanks for adding another test below
shouldn't this test/assertion still pass after this change?
There was a problem hiding this comment.
shouldn't this test/assertion still pass after this change?
yes, you are right... it can make sense to keep this line also as in case of password which will be as default string - it will also work. I added this line back to this pull.. 0ed3ba4 + will check sanitize function based on bytes/date/integer data types
There was a problem hiding this comment.
@wing328 - can you please check and confirm that now is ok?
restore sanitize test for serialization with different data types
|
cc |
…ecretStr ) BUG#16086 (2nd pull) (OpenAPITools#18023) * 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
#16086
handling SecretStr for the password field
this is 2nd pull try
history and more explanation in: #17310
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)