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

swagger-initializer.js is sent endcoded in the JVM's default charset #2207

Closed
roded opened this issue Apr 14, 2023 · 5 comments
Closed

swagger-initializer.js is sent endcoded in the JVM's default charset #2207

roded opened this issue Apr 14, 2023 · 5 comments
Labels
incomplete incomplete description: Make sure you Provide a Minimal, Reproducible Example - with HelloController

Comments

@roded
Copy link

roded commented Apr 14, 2023

Describe the bug

The swagger-initializer.js file being accepted by the browser is in the the JVM's default charset.
So on systems in which the default charset isn't UTF*, the browser seems to be getting a file which is unreadable.
Downloading the file and opening it up in the system's default encoding shows the correct contents.

To Reproduce
You'll have to load the JVM with a non-default charset.

  • What version of spring-boot you are using?
    2.7.10

  • What modules and versions of springdoc-openapi are you using?
    springdoc-openapiUi = "org.springdoc:springdoc-openapi-ui:1.7.0"

  • What is the actual and the expected result using OpenAPI Description (yml or json)?
    N/A, the OpenAPI JSON loads fine

  • Provide with a sample code (HelloController) or Test that reproduces the problem
    N/A

Expected behavior

  • A clear and concise description of what you expected to happen.
    The swagger-initializer.js file accepted by the browser should be readable.

  • What is the expected result using OpenAPI Description (yml or json)?
    N/A

Screenshots
image
image

Additional context
N/A

@bnasslahsen
Copy link
Contributor

@roded,

Your issue is not reproducible.
Without Provide a Minimal, Reproducible Example - with HelloController that reproduces the problem, or directly proposing a PR, we can do nothing for your issuel

@bnasslahsen bnasslahsen added the incomplete incomplete description: Make sure you Provide a Minimal, Reproducible Example - with HelloController label Apr 16, 2023
@roded
Copy link
Author

roded commented Apr 17, 2023

@bnasslahsen , of course, apologies.

See here for a reproduction: https://github.com/roded/springdoc-openapi-issue-2207

I suspect that the issue is the following snippet in SwaggerIndexPageTransformer which does not specify a charset in getBytes():

if (isIndexFound) {
    String html = defaultTransformations(resource.getInputStream());
    return new TransformedResource(resource, html.getBytes());
}

The issue does not reproduce when running on JDK 18, not sure why that is.

@bnasslahsen
Copy link
Contributor

@roded,

Issue reproduced and should be fixed.

@roded
Copy link
Author

roded commented Apr 17, 2023

Much obliged @bnasslahsen . When is a new release expected? TY

@bnasslahsen
Copy link
Contributor

Hopefully, by the end of this month

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incomplete incomplete description: Make sure you Provide a Minimal, Reproducible Example - with HelloController
Projects
None yet
Development

No branches or pull requests

2 participants