loopbackio / loopbackio/loopback-connector-openapi
OAS 3.0.1 Dictionaries are parsed incorrectly
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 8
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Steps to reproduce
Define a OAS with the following definition endpoint definition:
"/price/getprice": {
"get": {
"tags": [
"price-controller"
],
"summary": "Get the price of data",
"operationId": "getPrice",
"parameters": [
{
"name": "parameters",
"in": "query",
"description": "characteristic parameters of the data",
"required": true,
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
],
"responses": {
"200": {
"description": "price of data",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
Current Behavior
It generates the following service
export interface PriceControllerService {
getPrice(parameters: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[additionalProperty: string]: any;
}): Promise<string>;
}
This result is wrong! Based on the documentation https://swagger.io/docs/specification/data-models/dictionaries/ it should pass all the query attributes directly, instead of trying nest them under parameters: {}.
So when calling the endpoint -> /price/getprice?a=1&b=2 it throws the error MISSING_REQUIRED_PARAMETERS
{
"error": {
"statusCode": 400,
"name": "BadRequestError",
"message": "Required parameter parameters is missing!",
"code": "MISSING_REQUIRED_PARAMETER"
}
}
Expected Behavior
It should support Maps and Dictionaries and somehow allow dynamic parameters throught the query. Is there any solution implemented? Thanks!
Link to reproduction sandbox
Additional information
Related Issues
See Reporting Issues for more tips on writing good issues
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
No source file or test is named. Start by reproducing the OAS 3.0.1 definition in the OpenAPI connector and trace how the dictionary query parameter becomes the generated TypeScript service signature; done means query attributes such as a=1 and b=2 are accepted directly without a missing-parameters error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100