swagger-api / swagger-api/swagger-client
swagger-client npm module fails to resolve $ref for parameters
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 765
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 6
Description
when using the swagger-client npm module, the client fails to resolve $ref references for parameters defined in the OpenAPI specification.
For example, in the case of Open Api Contract 1, the query parameters are not being included in the URL, whereas in Open Api Contract 2, they are correctly passed.
const response = SwaggerClient.execute({
spec: openApiContract,
method: '...',
pathName: '...',
{
limitParam: 10,
offsetParam: 5
},
securities: {...},
attachContentTypeForEmptyPayload: true,
requestContentType: 'application/json',
responseContentType: 'application/json'
});
Open Api Contract 1:
openapi: 3.0.0
info:
title: Sample API
version: 1.0.0
components:
parameters:
limitParam:
name: limit
in: query
description: Limits the number of returned results
required: false
schema:
type: integer
format: int32
offsetParam:
name: offset
in: query
description: Offset from which to start returned results
required: false
schema:
type: integer
format: int32
paths:
/items:
get:
summary: Get items
parameters:
- $ref: '#/components/parameters/limitParam'
- $ref: '#/components/parameters/offsetParam'
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: integer
name:
type: string
Open Api Contract 2:
openapi: 3.0.0
info:
title: Sample API
version: 1.0.0
paths:
/items:
get:
summary: Get items
parameters:
- name: limit
in: query
description: Limits the number of returned results
required: false
schema:
type: integer
format: int32
- name: offset
in: query
description: Offset from which to start returned results
required: false
schema:
type: integer
format: int32
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: integer
name:
type: string
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with Open Api Contract 1 and Open Api Contract 2 using SwaggerClient.execute. Trace how parameter references under components.parameters are resolved before the request URL is built. Done means the referenced limit and offset parameters are included in the URL as they are for inline parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100