swagger-api / swagger-api/swagger-codegen
[Python] configuration.client_side_validation is ignored
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The generated python client has the following setting in its class Configuration:
# Disable client side validation
self.client_side_validation = True
However, when set to false, deserialization still tries to do validation and fails if the received data is wrong.
This is because when deserializing a model, the model expects to receive the configuration in its __init__ method, but __deserialize_model forgets to pass this parameter when creating the class.
When a model class is created without a configuration, it recreates a default configuration which explains why ours is ignored.
The configuration should always be passed to the model when deserializing it. I'm working on a PR to fix that.
Swagger-codegen version
2.4.29
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/swagger-codegen/src/main/resources/python/api_client.mustache at __deserialize_model, then compare its model construction with the configuration parameter expected in modules/swagger-codegen/src/main/resources/python/model.mustache. Verify the generated Python client with client_side_validation set to false and invalid received data, and confirm deserialization no longer rejects it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100