swagger-api / swagger-api/swagger-codegen

[JAVA] codegen not generating OAuth2 password flow

Open
#7,934 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I used the code generator to create a client library for my API, using an OpenAPI 2.0 Swagger json.

The swagger has both securityDefinitions and security objects specified, but no OAuth token refresh flow was produced. As far as I can tell, the generated APIClient requires a fresh token to be provided externally.

Do I need to manually code the logic for refreshing the OAuth token?

  "securityDefinitions": {
    "oAuth2Password": {
      "type": "oauth2",
      "flow": "password",
      "tokenUrl": "https://api.buildingos.com/o/token/",
      "scopes": {}
    },
  "security": [
    {
      "oAuth2Password": []
    }
  ]
Swagger-codegen version

2.3.1

Swagger declaration file content or url

https://gist.github.com/JurisPuchin/7f1e4208dae61bbcb54694b355dd5a38

Command line used for generation

java -jar swagger-codegen-cli-2.3.1.jar generate -i original_raw_oauth_resp3.json -l java -o oath_test8

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

Reproduce the report with swagger-codegen-cli 2.3.1, the linked Swagger declaration, and the shown Java generation command. Inspect the generated APIClient and the Java code-generation templates to determine whether the OAuth2 password flow is represented; done means either generating the expected password-flow handling or documenting that token refresh remains external.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, authentication, 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.