swagger-api / swagger-api/swagger-codegen

[Typescript-Node] - Referencing an enum definition from another definition does not output an enum

Open
#9,021 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Referencing an enum definition from another definition does not output an enum

Swagger-codegen version

2.4.1-SNAPSHOT

Swagger declaration file content or url
swagger: '2.0'

info:
  version: "2.0.1"
  title: API
  description: API

tags:
  - name: ignore-v1
    description: "Ignored items related APIs"

basePath: /api/v1
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json

paths:      
  /api/v1/ignore/rules/{ruleId}:
      put:
        tags:
          - ignore-v1
        description: Update ignore rule.
        produces:
          - application/json
        parameters:
          - name: ruleId
            in: path
            description: The ignore id of the item to update.
            required: true
            type: string
          - name: body
            in: body
            description: ignore request.
            required: true
            schema:
               $ref: '#/definitions/update-ignore-request'
        responses:
          200:
            description: Rule updated successfully.
          400:
            description: Bad request. Missing parameters or path not valid.
          409:
            description: Rule already exists.
          500:
            description: Internal server error.

definitions:
  update-ignore-request:
    type: object
    properties:
      pattern: 
        type: string
        example: /src/mwysfolder
      condition: 
          $ref: '#/definitions/ignore-condition'
      reason: 
        type: string
        example: ctor

  ignore-condition:
      type: string
      enum:
        - StartsWith
        - EndsWith
        - ExactMatch
        - Contains
      example: ExactMatch
Command line used for generation

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate
-i api.yml
-l typescript-node
-o samples/client/typescript-node

Steps to reproduce

save the above spec as api.yml and run the above command.

Related issues/PRs

None that I could find.

Suggest a fix/enhancement

print warnings to console explaining why an enum was not created as an enum

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the supplied api.yml and the swagger-codegen CLI command targeting samples/client/typescript-node. Start by tracing the typescript-node generator's handling of the referenced ignore-condition definition, then inspect the generated model output. Done means the referenced enum is represented correctly, or the generator emits the requested explanatory warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.