Skip to content

the generated JSDoc comment does not include the descriptions from the nested schemas with AnyOf #2142

Open
@alewin

Description

@alewin

openapi-typescript version

7.6.1

Node.js version

22.11.0

OS + version

macOS 14.6.1

Description

the generated JSDoc comment does not include the descriptions from the nested schemas with AnyOf

Proposal PR: #2143

Reproduction

Steps to Reproduce

  1. define a schema with a property using anyOf as shown above.
  2. run the code generation process
pnpm exec openapi-typescript ./openapi-definition.yaml -o ./schema.ts
  1. the resulting jsdocs comment for the property item lacks the nested description
item?: boolean | string;

Example openapi-definition.yaml

openapi: 3.0.0
info:
  title: Sample API
  description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
  version: 0.1.9

servers:
  - url: http://api.example.com/v1
    description: Optional server description, e.g. Main (production) server
  - url: http://staging-api.example.com
    description: Optional server description, e.g. Internal staging server for testing

paths:
  /users:
    get:
      summary: Returns a list of users.
      description: Optional extended description in CommonMark or HTML.
      responses:
        "200": # status code
          description: A JSON object containing user names
          content:
            application/json:
              schema:
                type: object
                properties:
                  item:
                    oneOf:
                      - type: boolean
                        description: Description 1
                      - type: string
                        description: Description 2
                required:
                  - item

Expected result

expected result is:

/** @description description 1 | description 2 */
item?: string | boolean;

Required

  • My OpenAPI schema is valid and passes the Redocly validator (npx @redocly/cli@latest lint)

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-tsRelevant to the openapi-typescript library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions