openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

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

Open alewin opened this issue 9 months ago • 0 comments

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: https://github.com/openapi-ts/openapi-typescript/pull/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

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

Extra

alewin avatar Feb 06 '25 15:02 alewin