Enhance OpenAPI Generator Pydantic Models with typings

Open
#10 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start by locating the Jinja2 model template that generates the Pydantic classes, then inspect spec/sdk_test.py around the reported constructor usage. Compare explicit init generation with the alternative .pyi approach. Done means regenerated models accept snake_case arguments at runtime and MyPy passes without call-arg ignores.

Written by the indexing model from the issue text.

Description

Title: Enhance OpenAPI Generator Pydantic Models with Explicit __init__ Signatures for Snake‑case Fields


What

Our generated Pydantic models only declare field aliases, not an explicit constructor signature, so MyPy reports errors when consuming code passes snake_case keyword arguments:

Minimal example

# Generated by OpenAPI Generator (no explicit __init__)
class V2SetHumanProfile(BaseModel):
    given_name: Annotated[str, Field(alias="givenName")]
    family_name: Annotated[str, Field(alias="familyName")]
    # … other fields …
# In test or client code:
profile = V2SetHumanProfile(
    given_name="John",
    family_name="Doe",
)
spec/sdk_test.py:35: error: Unexpected keyword argument "given_name" for "V2SetHumanProfile"; did you mean "givenName"?  [call-arg]

At runtime, Pydantic’s populate_by_name=True accepts given_name/family_name, but MyPy only “sees” the aliased fields and so flags the snake_case kwargs as invalid.


Why

  • Improved DX & autocompletion
    Developers expect Python‑style constructor arguments (given_name, not givenName).
  • Stronger static guarantees
    Eliminates the need for # type: ignore[call-arg] or hand‑written stubs.
  • Consistency
    Keeps runtime behavior and static types in sync.

How

  1. Inject explicit __init__ in the generator template
    Update the Jinja2 model template to emit a constructor exposing snake_case names:

  2. (Alternative) Generate .pyi stubs
    Produce companion stub files with explicit __init__ signatures.

  3. Regenerate the SDK & validate

    • Run the generator with the updated template.
    • Confirm constructors accept snake_case args.
    • Verify MyPy passes without ignores.
Dominant language
Python
Stars
16
Forks
3
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

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.

More from zitadel/client-python

All issues in zitadel/client-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.