OpenAPITools / OpenAPITools/openapi-generator
[BUG] Patch request parameters follow a different format from the Post request
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The generated typescript-axios types don't match the types defined inside the spec file. For the given spec file shown below the generator creates parameters in different ways from the Post and Patch request
For Post request it creates one parameter for every route parameter + one for the requestBody
const params = {
param1: number,
param2: number,
body: Body
}
but for the Patch request it spreads the body params
const params = {
param1: number,
param2: number,
bodyProperty1: any,
bodyProperty2: any,
bodyProperty3: any,
...
}
https://codesandbox.io/s/xenodochial-morning-cbhqyh?file=/src/api.ts
openapi-generator version
6.0.1 Docker image
OpenAPI declaration file content or url
Generation Details
docker run --rm \
-v "${PWD}/web-app-material/sdk:/local" \
-v "${PWD}/nest-backend:/nest-backend" \
-v "${PWD}/openapi-templates:/templates" \
openapitools/openapi-generator-cli:v6.0.1 generate --global-property skipFormModel=false \
-i "/nest-backend/openApiSpec.json" \
-g typescript-axios \
-o /local \
-t templates/typescript-axios \
--additional-properties=useSingleRequestParameter=true
Steps to reproduce
Related issues/PRs
Suggest a fix
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 with the typescript-axios templates supplied through -t templates/typescript-axios and compare the generated POST and PATCH parameter signatures using the linked OpenAPI declaration or CodeSandbox. Reproduce with the provided Docker v6.0.1 command; done means both operations represent request parameters consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100