swagger-api / swagger-api/swagger-client

V2 Compatibility mode doesn't work for tag interface

Open
#3,635 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P3 pull-request-welcome type: bug version: 2.x
Dominant language
JavaScript
Stars
2.7k
Forks
765
Avg merge
1d 1h
Merged PRs (30d)
6

Description

Q&A (please complete the following information)
  • OS: Windows 11
  • Environment: Edge 127
  • Method of installation: npm
  • Swagger-Client version: 3.28.2
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Swagger-Client usage:

const client = SwaggerClient({url: url, v2OperationIdCompatibilityMode: true})
Describe the bug you're encountering

v2OperationIdCompabilityMode doesn't actually work, it creates the correctly named interface functions within 'client.apis' but when making a request it fails to resolve the operation ID to an endpoint within the spec.

It seems to be because the v2 compatibility flag isn't passed to getOperationRaw and then down to opId (where the flag is handled).

Looking at the unit tests that were added it seems they only check that the tag function is created not that the request actually succeeds.

To reproduce...

Steps to reproduce the behavior:

  1. Have a path that contains a route parameter (/some/path/{id})
  2. Ensure v2 compatibility mode is on
  3. Try to call client.apis.tag.get_some_path_id
  4. buildRequest throws as getOperationRaw cannot resolve the operation ID to a spec path
Expected behavior

The call is correctly translated to a request to /some/path/{id}

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/index.js and trace how getOperationRaw resolves the operation ID through opId. Review the unit tests added in pull request #1283, then add coverage for calling client.apis.tag.get_some_path_id with a route parameter. Done means the call resolves to /some/path/{id} and buildRequest succeeds.

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
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.