OpenAPITools / OpenAPITools/openapi-generator
[BUG] Openapi feign client generation body/query param mismatch
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- [ x] Have you provided a full/minimal spec to reproduce the issue?
- [ x] Have you validated the input using an OpenAPI validator (example)?
- [ x] Have you tested with the latest master to confirm the issue still exists?
- [x ] Have you searched for related issues/PRs?
- [x ] What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Given this example specification describing the request body as a form model and the generated feign api interface.
The actual behaviour is that the feign client sends the parameters as query params not in the the body.
The fix for this is that the params should be wrapped in a form model dto and specified in the generated code as
RequestBody
eg
ResponseEntity<Void> authenticationServiceAuthorizePost(
@Parameter(name = "Content-Type", description = "") @RequestHeader(value = "Content-Type", required = false) String contentType,
@RequestBody AuthRequestDto authRequestDto
...more params generated...
);
/authentication-service/authorize:
post:
tags:
- Auth
summary: Authorize
requestBody:
content:
application/x-www-form-urlencoded:
schema:
properties:
redirect_uri:
type: string
example: http://localhost
client_id:
type: string
example: asdf
encoding:
redirect_uri:
allowReserved: true
client_id:
allowReserved: true
parameters:
- name: Content-Type
in: header
schema:
type: string
example: application/x-www-form-urlencoded
responses:
'200':
description: Successful response
content:
application/json: {}
@Operation(
operationId = "authenticationServiceAuthorizeGet",
summary = "API-AS02 Authorize",
tags = { "Auth" },
responses = {
@ApiResponse(responseCode = "200", description = "Successful response")
}
)
@RequestMapping(
method = RequestMethod.GET,
value = "/authentication-service/authorize",
produces = "application/json",
consumes = "application/x-www-form-urlencoded"
)
ResponseEntity<Void> authenticationServiceAuthorizePost(
@Parameter(name = "Content-Type", description = "") @RequestHeader(value = "Content-Type", required = false) String contentType,
@Parameter(name = "redirect_uri", description = "") @Valid @RequestParam(value = "redirect_uri", required = false) String redirectUri,
@Parameter(name = "client_id", description = "") @Valid @RequestParam(value = "client_id", required = false) String clientId,
...more params generated...
);
openapi-generator version
4.3.0
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 repository file or test is named. Start with the supplied OpenAPI YAML and compare the generated Feign interface, especially the form fields currently emitted as @RequestParam values; done means those fields are represented in the request body as the expected form model and sent as body parameters rather than query parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100