Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
alewin opened this issue Feb 6, 2025 · 0 comments
Labels
bug Something isn't working openapi-ts Relevant to the openapi-typescript library

Comments

@alewin
Copy link

alewin commented Feb 6, 2025

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

@alewin alewin added bug Something isn't working openapi-ts Relevant to the openapi-typescript library labels Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-ts Relevant to the openapi-typescript library
Projects
None yet
Development

No branches or pull requests

1 participant