Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
5 of 6 tasks
JochenReinhardt opened this issue Jun 21, 2022 · 1 comment · Fixed by #12677
Closed
5 of 6 tasks

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

JochenReinhardt opened this issue Jun 21, 2022 · 1 comment · Fixed by #12677

Comments

@JochenReinhardt
Copy link
Contributor

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>

JochenReinhardt added a commit to JochenReinhardt/openapi-generator that referenced this issue Jun 23, 2022
@JochenReinhardt
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant