OpenAPITools / OpenAPITools/openapi-generator
[REQ] Generate @HeaderParam("Authorization") for OAuth2.0 authentication securitySchemes.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
Problem:
When we write the following open API definition and generate code for Java, @HeaderParam("Authorization") is not included in the arguments of the API.
components:
securitySchemes:
oAuthSample: # <---- arbitrary name
type: oauth2
description: This API uses OAuth 2 with the implicit grant flow. [More info](https://api.example.com/docs/auth)
flows:
authorizationCode:
authorizationUrl: https://slack.com/oauth/authorize
tokenUrl: https://slack.com/api/oauth.access
scopes:
read_pets: read your pets
write_pets: modify pets in your account
paths:
/pets:
patch:
summary: Add a new pet
security:
- oAuthSample:
- write_pets
- read_pets
Describe the solution you'd like
Add @HeaderParam("Authorization") to the arguments of the API method generated by openapi-codegen.
Describe alternatives you've considered
Define Authorization as header param like below.
paths:
/pets:
patch:
summary: Add a new pet
security:
- oAuthSample:
- write_pets
- read_pets
parameters:
- in: header
name: Authorization
schema:
type: string
required: true
Additional context
N/A
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 by tracing how the Java generator handles OAuth2.0 securitySchemes and assembles generated API method arguments. Compare that path with the explicit Authorization header parameter shown in the issue; done means OAuth2.0-protected methods include @HeaderParam("Authorization") without requiring the parameter to be declared manually.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100