Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #12656
Something went wrong while setting issue due date.
Closed
Open
Issue created 3 years ago by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items
  • New related issue

  • Report abuse to administrator

  • New related issue

  • Report abuse to administrator

[BUG][JAVA] OAuth authorizationUrl is HTML-escaped

Closed

[BUG][JAVA] OAuth authorizationUrl is HTML-escaped

Created by: JochenReinhardt

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I am trying to generate a Java client (feign library) for an Open API spec using OAuth via openapi-generator-maven-plugin, version 6.0.0. The token URL contains parameters, e.g. https:/auth-server/token?key=value. The generator HTML-escapes the URL, resulting in https:/auth-server/token?key=value.

The generated client cannot authenticate, because the token URL is corrupted.

openapi-generator version

openapi-generator-maven-plugin, version 6.0.0 also occurs with version, 5.4.0

OpenAPI declaration file content or url

The spec contains the following securityScheme:

    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https:/auth-server/token?key=value",
            "scopes": {
              "read_items": "read items"
            }
          }
        }
      }
    }
Generation Details

When using mvn generate-sources, the generated client contains an invalid token URL.

The maven build file configures the plugin:

<configuration>
    <inputSpec>src/main/open-api/spec.json</inputSpec>
    <generatorName>java</generatorName>
    <configOptions>
        <library>feign</library>
        <dateLibrary>java8-localdatetime</dateLibrary>
     </configOptions>
</configuration>
Steps to reproduce
  • define an Open API spec with OAuth token URL containing URL parameters
  • generate client using maven plugin
Suggest a fix

HTML-escaping the token / authorization URL is not correct. It should be avoided by fixing the corresponding Mustache template. The token URL and the authorization URL must not be HTML-escaped. This can be done by using {{{ to refer to the variables. basePath is referenced correctly in the Java-Feign template. See modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache

As a workaround, I added a fixed version of the java-feign template and set it up in the maven plugin configuration: <templateDirectory>src/main/open-api/templates</templateDirectory>

An error occurred while loading designs. Please try again.
Tasks
0
server returned results with length 5, expected length of 9

Linked items
0

Link issues together to show that they're related. Learn more.

Activity


  • Administrator
    Administrator @root · 3 years ago
    Author Contributor

    Created by: JochenReinhardt

    #12677 opened a pull request to fix all java-based generators using tokenURL or authorizationURL.

Please register or sign in to reply
0 Assignees
None
Assign to
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
Due date
None
None
None
Time tracking
No estimate or time spent
Confidentiality
Not confidential
Not confidential

You are going to turn on confidentiality. Only project members with at least the Reporter role, the author, and assignees can view or be notified about this issue.

Lock issue
Unlocked
0
0 participants
Reference:

Menu

Explore Projects Groups Snippets