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

Merged
RA
19d ago
+65-2

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