OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Feign] Incorrect generated format with Content-Type: application/x-www-form-urlencoded

Open
#21,266 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Hi, we are trying to genenerate an feign client to call an Oauth2 token method. In curl, this call is like this:

curl --request POST \
  --url https://xxxxxxxxxxxxxx/oauth2/v1/token \
  --header 'Authorization: Basic XXXXXXXX' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --header 'User-Agent: insomnia/9.3.2' \
  --data username=XXXXX \
  --data password=XXXXX \
  --data grant_type=password \
  --data scope=XXXXXXXXXXX/super_scope+offline_access 

but when we run the openapi generator, feign is doing this call:

https://xxxxxxxxx/oauth2/v1/token?username=XXXXXX&password=XXXXX&grant_type=password&scope=XXXXX/super_scope+offline_access'

that retuns a bad request exception

openapi-generator version

3.0.1

OpenAPI declaration file content or url
/token:
post:
tags:
- "Oauth2"
summary: "Generate new access and refresh token"
description: ""
operationId: "token"
parameters:
- in: "header"
name: "Authorization"
description: "Basic authentication"
required: true
schema:
type: string
requestBody:
description: Session credentials
content:
application/x-www-form-urlencoded:
schema:
$ref: "#/components/schemas/TokenRequest"
responses:
"200":
description: "Successful operation"
content:
application/json:
schema:
title: "TokenResponse"
oneOf:
- $ref: "#/components/schemas/OauthSuccess"
- $ref: "#/components/schemas/OauthError"
"400":
description: "Bad request"
content:
application/json:
schema:
$ref: "#/components/schemas/OauthError"
"401":
description: "Forbidden"
content:
application/json:
schema:
$ref: "#/components/schemas/OauthError"

Can help me to try to generate the request so that the parameters appear in the body and not in the URL?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Feign generator's handling of the supplied application/x-www-form-urlencoded requestBody and compare the generated request with the OpenAPI declaration. Reproduce the token operation, then verify that username, password, grant_type, and scope are encoded in the request body rather than appended to the URL.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.