swagger-api / swagger-api/swagger-client

parameter builder uses a comma instead of an empty string

Open
#1,708 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug version: 3.x
Dominant language
JavaScript
Stars
2.7k
Forks
765
Avg merge
1d 1h
Merged PRs (30d)
6

Description

Hello,

it seems that an additional , can appended to the path in some cases and it has been detected using swagger ui's execution feature (swagger-ui-dist@3.32.5). It could be traced back to the following line:

https://github.com/swagger-api/swagger-js/blob/3627eadb1387975c6d7afae766d27e6cb286b846/src/execute/oas3/parameter-builders.js#L26

The default behavior of Array.join will be used if styledValue is undefined.

The following yaml definition creates this case, if the input field in swagger ui remains untouched

paths:
  /openapi/specification{plural}:
    parameters:
    - name: plural
      in: path
      required: false
      schema:
        type: string
        pattern: "s?

Many thanks in advance.

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 in src/execute/oas3/parameter-builders.js at the linked parameter-builder line and trace how the path parameter value is assembled when styledValue is undefined. Reproduce the YAML case with an untouched Swagger UI input, then verify that the generated path uses an empty value rather than an additional comma.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.