loopbackio / loopbackio/loopback-connector-openapi
OAS 3.0.1 Dictionaries are parsed incorrectly
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 8
- Fork
- 4
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Non sono indicati file sorgente né test. Inizia riproducendo la definizione OAS 3.0.1 nel connettore OpenAPI e segui come il parametro di query di tipo dizionario diventa la firma del servizio TypeScript generata; il lavoro è completato quando attributi di query come a=1 e b=2 vengono accettati direttamente senza un errore per parametri mancanti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, openapi, typescript
- Ambito
- api, backend
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100