OpenAPITools / OpenAPITools/openapi-generator

[REQ] Have the ability to change model validation exceptions to warnings in Python client

Open
#19,357 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

Sometimes model validation will throw an exception and fail for a fairly innocuous change, such as adding a new value to an enum in an API response. When this happens I would like to be able to log some kind of warning, e.g. unexpected enum value received, but still to continue processing the API response and return a 200.

Describe the solution you'd like

I would like to be able to control the behaviour in this scenario so that I can control whether or not an exception is thrown and a 500 is returned, or if I just log a warning that I can monitor for and fix later.

As far as I can tell the client_side_validation configuration value is not used for anything in the Python client.

I would like to be able to use this configuration value to dictate whether or not the model validation that takes place here (template code here) throws an exception or logs an error and returns normally.

Describe alternatives you've considered

I am not sure what alternatives are possible.

Additional context

I'm aware this could be resolved with proper API versioning and coordinated releases but in reality this is harder to implement. I would rather say that I accept model validation errors but would still like to receive the response from the client if this occurs.

I am happy to contribute an MR if this change is acceptable, or to discuss alternatives.

Tags

Tagging Python technical committee for visibility @cbornet @tomplus @krjakbrjak @fa0311 @multani

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 with modules/openapi-generator/src/main/resources/python/configuration.mustache to trace client_side_validation, then inspect model_generic.mustache and the generated validation in samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py. Determine how the setting should control exceptions versus warnings, and confirm that generated clients continue processing responses while reporting validation problems.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.