openapi-generators / openapi-generators/openapi-python-client

`Input should be a valid string` for integer keys in openapi.yaml

Open
#1,333 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2k
Forks
293
Avg merge
34m
Merged PRs (30d)
1

Description

Describe the bug
When generating classes from openapi.yaml with integers as keys (e.g. 200), I get the error:

paths./api/events.get.responses.200.[key]
  Input should be a valid string [type=string_type, input_value=200, input_type=int]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type

Is there a chance to ignore those errors and fall back to string for integer keys?

OpenAPI Spec File
Link to an OpenAPI document

Desktop (please complete the following information):

  • OS: macOS 26.0.1
  • Python Version: 13.3
  • openapi-python-client version: 0.26.2

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 by reproducing the failure with the linked openapi.yaml and openapi-python-client 0.26.2, focusing on the response key at paths./api/events.get.responses.200. The work is done when integer keys are accepted during class generation and treated as strings instead of producing the Pydantic validation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.