fix: fall back to schema key when two schemas share a title#1448
Open
alexander-wenzel-dev wants to merge 1 commit into
Open
fix: fall back to schema key when two schemas share a title#1448alexander-wenzel-dev wants to merge 1 commit into
alexander-wenzel-dev wants to merge 1 commit into
Conversation
Tools like FastAPI emit duplicate `title` values for input and output variants of the same model (for example `Thing-Input` and `Thing-Output` both carrying `title: Thing`). The class name is derived from the title, so the second variant collided with the first and was rejected with `Attempted to generate duplicate models`. The generator emitted a warning and silently dropped the schema along with every endpoint that referenced it. When the title-derived class name is already taken, the second variant now falls back to a class name derived from its schema key (`Thing-Output` becomes `ThingOutput`) provided that key is unique. The original schema's name is preserved, and both variants and their endpoints generate. A functional test in `end_to_end_tests/functional_tests` covers the inline spec, and a unit test in `tests/test_parser/test_properties/test_model_property.py` exercises the new branch in `ModelProperty.build`.
alexander-wenzel-dev
added a commit
to alexander-wenzel-dev/mealie-mcp
that referenced
this pull request
Jun 6, 2026
Adds a [tool.uv.sources] override resolving openapi-python-client from alexander-wenzel-dev/openapi-python-client at branch pin/mealie-mcp-combined. The branch carries two unmerged generator fixes (upstream PRs openapi-generators/openapi-python-client#1448 and openapi-generators/openapi-python-client#1449) that unblock the Recipe-Input / Recipe-Output models and the PUT/PATCH recipe endpoints in the generated client. This commit only changes resolution; the generated client tree is untouched and gets regenerated in a separate PR. Removal plan is inline in pyproject.toml.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: fall back to schema key when two schemas share a title
Summary
When two component schemas declare the same
title, the second one wassilently dropped along with every endpoint that referenced it. This PR
makes the second variant fall back to a class name derived from its
schema key so both schemas survive.
Problem
Tools like FastAPI emit duplicate
titlevalues for input and outputvariants of the same model (for example
Thing-InputandThing-Outputboth carrying
title: Thing). The class name is derived from the title,so the second variant collides with the first and is rejected with
Attempted to generate duplicate models. The generator emits a warningbut exits 0, so the schema and every endpoint that referenced it are
silently dropped from the generated client.
Minimal reproduction
Before this PR:
Thing-Outputand any endpoint that references it areabsent from the generated client, and the only signal is a warning on
stderr.
Fix
In
ModelProperty.build, when the title-derived class name is alreadytaken, fall back to a class name derived from the schema key
(
Thing-OutputbecomesThingOutput) provided that key is unique.The original schema's name is preserved, and both variants and their
endpoints generate.
The fallback is guarded by
data.title and nameso it only triggersin the duplicate-title case. If the fallback name also collides, the
existing
Attempted to generate duplicate modelserror path stillfires unchanged.
Tests
end_to_end_tests/functional_tests/generated_code_execution/test_title_collisions.py— uses the inline spec above and asserts both
ThingandThingOutputexist and round-trip correctly.tests/test_parser/test_properties/test_model_property.py(
TestBuild::test_model_name_conflict_fallback) exercises the newbranch in
ModelProperty.builddirectly.Local verification
All green on Python 3.14. 100% coverage on the changed file
(
model_property.py). Golden-record snapshot tests pass withoutregeneration — no generated output changes for any existing spec in
the upstream baseline.
Risk
name; the second falls back to the schema-key-derived name. For the
motivating
Thing-Input/Thing-Outputcase this is the desiredresult. A schema author who expected the second variant to claim
the title would see different output, but that case previously
errored out, so this is a strict improvement over the prior failure
mode.
ModelProperty.build; nothing else in the parser or templates istouched.
Related
Companion PR: #1449 — a second independent fix for
freeform-object defaults, surfaced from the same downstream spec.
The two PRs share no code paths and can land in either order.