OpenAPITools / OpenAPITools/openapi-generator

[REQ] [Python] A way to avoid strict type checking with an API Client

Open
#19,224 0 comments 1 reaction 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.

In the Python 7.6.0 generator, I am unable to bypass type checking. I want to use the API client with an incorrect body payload, but I cannot find a method to achieve this.

Describe the solution you'd like

A way to configure type checking or provide a method that bypasses type checking

Describe alternatives you've considered

  • Using model config, but this is not accessible with these types.
  • Using other available routes

Additional context

I apologize if this functionality is already available, but I have not been able to find a solution.

Generated post route

I need to pass a file that is not StrictBytes or StrictStr.

@validate_call
    def files_post(
        self,
        id: Annotated[StrictStr, Field(description="")],
        file: Union[StrictBytes, StrictStr],
        tags: Annotated[Optional[Dict[str, StrictStr]], Field(description="")] = None,
        region_or_country_code: Annotated[Optional[StrictStr], Field(description="")] = None,
        labels: Annotated[Optional[List[StrictStr]], Field(description="The file labels.")] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> FileMetadataInfo:

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 the generated Python files and the files_post entry point shown in the issue, then determine where @validate_call and the strict parameter types are introduced. Define how type-checking bypasses should be configured or invoked, and verify that a non-StrictBytes or non-StrictStr file can be passed without breaking normal validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.