Skip to content

fix(typescript-nestjs-server): peerDependencies typo and lost model name on primitive-union request bodies - #25708

Merged
wing328 merged 2 commits into
OpenAPITools:masterfrom
raschan:fix/typescript-nestjs-server-body-unions
Nov 17, 2026
Merged

wing328 merged 2 commits into
OpenAPITools:masterfrom
raschan:fix/typescript-nestjs-server-body-unions

Conversation

@raschan

@raschan raschan commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #25709
Fixes #25710

Two fixes found while using typescript-nestjs-server.

1. package.mustache typo. The template writes "peeerDependencies", which npm ignores, so the generated package declares no peer dependencies. Now "peerDependencies". (Only generated when npmName is set, so no sample changes.)

2. Named oneOf/anyOf request bodies without object members lose their model name. Repro:

paths:
  /lookup:
    post:
      operationId: lookupNode
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/NodeId' }
      responses: { '200': { description: ok } }
components:
  schemas:
    NodeId:
      oneOf:
        - { type: integer, format: int32 }
        - { type: string }

NodeId has no vars, so DefaultCodegen.addBodyModelSchema falls into the branch for inline unions (complexType contains " | "). For TypeScript generators the body's dataType, baseType, paramName and import then become number | string / numberString, and typescript-nestjs-server emits import { number | string } from '../models'. Same with anyOf.

The fix only takes that branch when there is no named model, so a named union falls through to the existing branch that already uses codegenModel.classname (what non-TypeScript generators get today). Inline unions are unchanged. Added DefaultCodegenTest#referencedPrimitiveUnionBodyKeepsModelName (fails before, passes after). DefaultCodegenTest and the TypeScript generator tests pass. Regenerating all samples gives no diff.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    Commit all changed files.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

TypeScript technical committee: @TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim @thekhegay

🤖 Generated with Claude Code

raschan and others added 2 commits November 17, 2026 12:37
The template wrote "peeerDependencies", which npm ignores, so the
generated package declared no peer dependencies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t object members

A named oneOf/anyOf body with only primitive members has no vars, so
addBodyModelSchema fell through to the inline-union branch. With
TypeScript generators this replaced the model name with the union type
string ("number | string") in dataType, baseType, paramName and imports,
e.g. typescript-nestjs-server emitted
`import { number | string } from '../models'`.

Only take the inline-union branch when there is no named model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

View guided diff | Re-trigger cubic

@wing328
wing328 merged commit 907dba6 into OpenAPITools:master Nov 17, 2026
15 checks passed
@wing328

wing328 commented Nov 17, 2026

Copy link
Copy Markdown
Member

thanks for the fix, which has been merged

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

Projects

None yet

2 participants