Skip to content
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

[BUG] Enum dataType in JSDoc is always string type #19570

Closed
5 of 6 tasks
052hide opened this issue Sep 12, 2024 · 0 comments · Fixed by #19571
Closed
5 of 6 tasks

[BUG] Enum dataType in JSDoc is always string type #19570

052hide opened this issue Sep 12, 2024 · 0 comments · Fixed by #19571

Comments

@052hide
Copy link
Contributor

052hide commented Sep 12, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When I generate code for an enum object defined with integer type, JSDoc outputs @enum {string}.

openapi-generator version

7.8.0

OpenAPI declaration file content or url
components:
  schemas:
    PetStatus:
      type: integer
      description: pet status in the store
      enum:
        - 1
        - 2
        - 3
full schema

schema.yml

openapi: 3.0.2
info:
  title: Sample
  version: 1.0.0
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: /api
paths:
  "/pets/{petId}":
    get:
      summary: Find pet by ID
      description: Returns a single pet
      operationId: getPetById
      parameters:
      - name: petId
        in: path
        description: ID of pet to return
        required: true
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Pet"
components:
  schemas:
    Pet:
      required:
        - id
        - name
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 10
        name:
          type: string
          example: doggie
        status:
          "$ref": "#/components/schemas/PetStatus"
    PetStatus:
      type: integer
      description: pet status in the store
      enum:
        - 1
        - 2
        - 3
Generation Details
/**
 * pet status in the store
 * @export
 * @enum {string}
 */
export const PetStatus = {
    NUMBER_1: 1,
    NUMBER_2: 2,
    NUMBER_3: 3
} as const;

expect

/**
 * pet status in the store
 * @export
 * @enum {number}
 */
export const PetStatus = {
    NUMBER_1: 1,
    NUMBER_2: 2,
    NUMBER_3: 3
} as const;
Steps to reproduce

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g typescript-axios -i ./schema.yml -o ./var/tmp/typescript-axios

Related issues/PRs
Suggest a fix
wing328 pushed a commit that referenced this issue Sep 12, 2024
* fix: enum dataType JSDoc

* chore: generate samples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant