swagger-api / swagger-api/swagger-codegen

[typescript-angular] Asterisk "*" parameters not handled

Open
#10,942 0 comments 0 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

In the openAPI 3.0 specification when there a parameter named "*" the SDK generator for typescript-angular doesn't handle that correctly. The results are typescript syntax errors.

Swagger-codegen version

3.0.25

Swagger declaration file content or url
"/entries/{id}/data/*": {
      "get": {
        "operationId": "entriesData",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "customTypes": "stringToId"
            }
          },
          {
            "in": "path",
            "name": "*",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uri-reference"
            }
          }]
          }
        }
      }
    },
Command line used for generation

swagger-codegen generate -i "http://127.0.0.1:${SERVER_PORT}${DOCS_PATH}/json" -l typescript-angular -o "${DESTINATION_ROOT}" --config "${PROJECT_ROOT}/sdk/sdk.config.json"

Where the configuration file states:

{
  "ngVersion": "11.2.4",
  "supportsES6": true
}
Steps to reproduce
  • Create a swagger definition containing a path with a parameter *
  • Generate the SDK
  • As result the variable name is invalid so there are compilation errors like these:
    image
Suggest a fix/enhancement

A possible workaround is renaming that parameter to something else but for automatically generated OAS3 definitions this operation can be tricky.

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

Start with the provided OpenAPI declaration and the typescript-angular generation command, using sdk.config.json as the configuration reference. Inspect the generated SDK for the path parameter named "*" and the resulting TypeScript syntax errors. Done means the generated SDK handles that parameter without compilation errors.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.