Description
Describe the bug
An OpenAPI Query Parameter with the name _
(or any _
within the parameter name) fails to generate the corresponding property name under services.gen.ts
(Fetch
client). Any instance of _
is being stripped from the resulting value (leading, trailing, or otherwise) in the translation of the snake_case
OpenAPI parameter key to the camelCase
property name, but if the parameter name is only _
the generated ts is broken.
Noting: If the parameter was _
the query parameter generated under services.gen.ts
is:
query: {
_: data.,
},
instead of
query: {
_: data._,
},
Also noting: Using _
as a name or character parameter in OpenAPI queries does not break the OpenAPI specification.
To Reproduce
Steps to reproduce the behavior:
Call the following openapi yaml using
yarn openapi-rq -i ./openapi.yaml
OpenAPI spec file
openapi: 3.1.0
info:
title: Test API
description: API for Test
version: development
security:
- test_auth:
- default
paths:
/reachable:
head:
summary: Reachable?
description: Does nothing and returns No Content
operationId: reachable
security: []
parameters:
- name: _
in: query
description: Optional parameter for avoiding caching
schema: {}
responses:
'204':
description: Success
Expected behavior
A clear and concise description of what you expected to happen.
Expected output
export class DefaultService {
/**
* Reachable?
* Does nothing and returns No Content
* @param data The data for the request.
* @param data._ Optional parameter for avoiding caching
* @returns void Success
* @throws ApiError
*/
public static reachable(
data: ReachableData = {},
): CancelablePromise<ReachableResponse> {
return __request(OpenAPI, {
method: "HEAD",
url: "/reachable",
query: {
_: data._,
},
});
}
}
Instead got output
export class DefaultService {
/**
* Reachable?
* Does nothing and returns No Content
* @param data The data for the request.
* @param data. Optional parameter for avoiding caching
* @returns void Success
* @throws ApiError
*/
public static reachable(data: ReachableData = {}): CancelablePromise<ReachableResponse> {
return __request(OpenAPI, {
method: 'HEAD',
url: '/reachable',
query: {
_: data.
}
});
}
}
Screenshots
If applicable, add screenshots or logs to help explain your problem.
- OS: Linuxmint
- Version
Description: Linux Mint 21.3
Release: 21.3
Codename: virginia - Node version: v20.14.0
Relevant package versions:
"devDependencies": {
"@7nohe/openapi-react-query-codegen": "^1.4.1",
"@tanstack/eslint-plugin-query": "^5.43.1",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"commander": "^12.1.0",
"ts-morph": "^22.0.0",
"typescript": "^5.1.6",
},
"packageManager": "yarn@4.3.0"