-
-
Notifications
You must be signed in to change notification settings - Fork 526
Closed
Description
What are the steps to reproduce this issue?
- Create a minimal OpenAPI example like
{
"info": {
"title": "My API",
"version": "1.0.0"
},
"openapi": "3.0.0",
"paths": {
"/test/{parameter}": {
"get": {
"parameters": [
{
"in": "path",
"name": "parameter",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
- Generate the functions.
- Use a parameter with special characters in above example.
What happens?
The parameter parameter is just string concatenated into the URL:
export const getTestParameter = <TData = AxiosResponse<void>>(
parameter: string,
options?: AxiosRequestConfig
): Promise<TData> => {
return axios.get(`/test/${parameter}`, options)
}As a result, requests fail.
What were you expecting to happen?
Strings in the path fragment must be encoded
export const getTestParameter = <TData = AxiosResponse<void>>(
parameter: string,
options?: AxiosRequestConfig
): Promise<TData> => {
return axios.get(`/test/${encodeURIComponent(parameter)}`, options)
}Any other comments?
URL encoding should take place here because neither the rest of the app should care about encoding nor is it possible to later encode a fully constructed URL.
A programmer would typically prefer to use a method like this to avoid having to worry about internals:
const someParam = 'special[s]/?test'
const results = useGetTestParameter(someParam)This bug happens at different places in the generated code.
What versions are you using?
"orval": "6.11.0-alpha.6"
lukaw3d and Maxim-Mazurok
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request