swagger-api / swagger-api/swagger-codegen

[Python] configuration.client_side_validation is ignored

Open
#11,966 2 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.