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] {path} is URL Encoded #18556

Open
6 tasks done
thoroughsoft opened this issue May 2, 2024 · 1 comment
Open
6 tasks done

[BUG][JAVA] {path} is URL Encoded #18556

thoroughsoft opened this issue May 2, 2024 · 1 comment

Comments

@thoroughsoft
Copy link

thoroughsoft commented May 2, 2024

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

When declaring /api/1.0/projects/{projectKey}/repos/{repositorySlug}/raw/{path},
{path} is URL encoded.
Generated code is

    String localVarPath = "/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/raw/{path}"
        .replace("{projectKey}", ApiClient.urlEncode(projectKey.toString()))
        .replace("{repositorySlug}", ApiClient.urlEncode(repositorySlug.toString()))
        .replace("{path}", ApiClient.urlEncode(path.toString()));

This mean that if I pass in
nifty_module/src/main/java/NiftyClass.java
as value for path, the final URL will be
/rest/api/1.0/projects/nifty_project/repos/nifty_repo/raw/nifty_module%2Fsrc%2Fmain%2Fjava%2FNiftyClass.java
instead of
/rest/api/1.0/projects/nifty_project/repos/nifty_repo/raw/nifty_module/src/main/java/NiftyClass.java
and in the end a 404.

Now I am the first to admit that I am not a super, duper swagger coder so maybe there is some setting or parameter that I can set to get me out of the problem. I have however not found any such information so for now I consider it a problem in the generated code.

openapi-generator version

7.3.0 and 7.5.0

OpenAPI declaration file content or url
  "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/raw/{path}":
    parameters:
      - description: the parent project key
        in: path
        name: projectKey
        required: true
        type: string
      - description: the repository slug
        in: path
        name: repositorySlug
        required: true
        type: string
      - description: the file path to retrieve content from
        in: path
        name: path
        required: true
        type: string
    get:
      operationId: retrieveRawContent
      description: |-
        Retrieve the raw content for a file path at a specified revision.
         <p>
         The authenticated user must have <strong>REPO_READ</strong> permission for the specified repository to call this
         resource.
      parameters:
        - description: the commit ID or ref to retrieve the content for.
          in: query
          name: at
          required: false
          type: string
        - description: |-
            if present or <code>"true"</code>, triggers the raw content to be markup-rendered and returned
                               as HTML; otherwise, if not specified, or any value other than <code>"true"</code>, the content
                               is streamed without markup
          in: query
          name: markup
          required: false
          type: string
        - description: |-
            (Optional) Whether the markup implementation should convert newlines to breaks.
                               If not specified, {@link MarkupService} will use the value of the
                               <code>markup.render.hardwrap</code> property, which is <code>true</code> by default
          in: query
          name: hardwrap
          required: false
          type: boolean
        - description: |-
            (Optional) true if HTML should be escaped in the input markup, false otherwise.
                               If not specified, {@link MarkupService} will use the value of the
                               <code>markup.render.html.escape</code> property, which is <code>true</code> by default
          in: query
          name: htmlEscape
          required: false
          type: boolean
      responses:
        "200":
          description: Successful Response
Generation Details

The example is an extract of the REST API for BitBucket, version 1.0
Full files can be found at
https://github.com/TwoStone/bitbucket-server-api/blob/master/bitbucket-server-api.yaml
and
https://github.com/gfleury/go-bitbucket-v1/blob/master/docs/bitbucketV1-rest-swagger.yaml

Note that one file is swagger 2.0 and one is openapi 3.0; both result in the same generation.

Steps to reproduce

Run the example files using the standard maven plugin and inspect the generated code.
Just look for any operation with {path} as the a parameter.

Related issues/PRs
Suggest a fix
@stefan521
Copy link
Contributor

Same issue reported here OAI/OpenAPI-Specification#892 (comment)

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

No branches or pull requests

2 participants