swagger-api / swagger-api/swagger-codegen
[Java] Auto-generated OAuth example is out of date for many HTTP backends
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The code sample from the auto-generated Api Doc:
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: Client Credentials
OAuth Client Credentials = (OAuth) defaultClient.getAuthentication("Client Credentials");
Client Credentials.setAccessToken("YOUR ACCESS TOKEN");
no longer matches the ApiCilent implementation for most HTTP backends:
ApiClient defaultClient = new ApiClient("Client Credentials");
defaultClient.setAccessToken("YOUR ACCESS TOKEN");
and also seems to be invalid syntax.
Swagger-codegen version
2.2.1
Suggest a fix/enhancement
Use 2nd provided example for HTTP backends (feign, retrofit, retrofit2) that support TokenRequestBuilder for automatic request and renew of Access Token (and add documentation for that functionality too).
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 modules/swagger-codegen/src/main/resources/Java/api_doc.mustache and compare its OAuth example with modules/swagger-codegen/src/main/resources/Java/libraries/feign/ApiClient.mustache. Check the corresponding feign, retrofit, and retrofit2 backends and their TokenRequestBuilder support. Done means the generated examples use valid, matching syntax and document automatic access-token requests and renewal where supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100