Skip to content

fix(openapi): preserve component schema names through dereferencing#416

Merged
ALagoni97 merged 1 commit into
mainfrom
fix/openapi-preserve-component-schema-names-main
Jul 15, 2026
Merged

fix(openapi): preserve component schema names through dereferencing#416
ALagoni97 merged 1 commit into
mainfrom
fix/openapi-preserve-component-schema-names-main

Conversation

@ALagoni97

Copy link
Copy Markdown
Contributor

Re-plants the changes from #414 directly onto main.

#414 targets the add_parameter_interface feature branch, which may not land. This PR contains only #414's own contribution (the three-dot delta add_parameter_interface...fix/openapi-preserve-component-schema-names) applied on top of the latest main, so it can merge independently.

What's included

The complete OpenAI component-schema-name fix from #414:

  • src/codegen/inputs/openapi/utils.ts — tag components.schemas / definitions entries with Modelina's x-modelgen-inferred-name after dereferencing so component names survive $ref inlining; namespaced names shorten to their last dot-segment when unambiguous.
  • src/codegen/inputs/openapi/parser.ts — wire the tagging into the parse pipeline.
  • src/codegen/inputs/openapi/generators/payloads.ts — copy response schemas before decorating with x-modelina-status-codes so status codes no longer leak across operations.
  • Tests: test/codegen/inputs/openapi/utils.spec.ts, test/codegen/generators/typescript/payload.spec.ts, and fixture test/configs/openapi-shared-items.json.

What's excluded

Everything contributed by the add_parameter_interface base branch (parameter-interface work). None of it is required for this fix — the delta applied to main with no conflicts.

Verification

  • tsc --noEmit — clean
  • eslint on changed sources — clean
  • jest across test/codegen/inputs/openapi and test/codegen/generators/typescript — 174 tests / 78 snapshots pass, no snapshot regeneration needed

🤖 Generated with Claude Code

Dereferencing inlines $ref targets and discards component names, so
Modelina named nested models after property paths - every 'items' array
item became 'ItemsItem', and models from different operations collided
on the same file and silently overwrote each other (a transactions
response ended up typed with the users item model).

Tag each components.schemas / definitions entry with Modelina's
x-modelgen-inferred-name hint right after dereferencing. Inlined
occurrences share object identity with the component entry, so the name
propagates to every usage site. Namespaced names shorten to their last
dot-segment when unambiguous (GetTransactions.Model.TransactionModel ->
TransactionModel), otherwise the full name is used. Standalone
component models reuse the same name so both generation paths resolve
to a single identical file.

Also copy response schemas before decorating with
x-modelina-status-codes: the schema object is shared post-dereference,
so mutating it leaked status codes across operations.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ALagoni97
ALagoni97 requested a review from jonaslagoni as a code owner July 15, 2026 17:19
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
the-codegen-project Ready Ready Preview, Comment Jul 15, 2026 5:20pm
the-codegen-project-mcp Ready Ready Preview, Comment Jul 15, 2026 5:20pm

@jonaslagoni

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.75.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants