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

OAuth and Swagger UI fails on 2.2.1.Final #19923

Closed
flynnk opened this issue Sep 5, 2021 · 2 comments · Fixed by #19976
Closed

OAuth and Swagger UI fails on 2.2.1.Final #19923

flynnk opened this issue Sep 5, 2021 · 2 comments · Fixed by #19976
Labels
area/swagger-ui env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@flynnk
Copy link

flynnk commented Sep 5, 2021

Describe the bug

Get
Uncaught TypeError: ui.initOAuth is not a function at window.onload ((index):40)
on the Javascript console when I navigate to the localhost in dev mode (to /q/swagger-ui).

This is an excerpt from the generated Swagger console index.html:

`


<script src="swagger-ui-bundle.js" charset="UTF-8"></script>
<script src="swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script>

        window.onload = function() {
            
            const ui = {
                url: '/q/openapi',
                dom_id: '#swagger-ui',
                deepLinking: true,
                presets: [SwaggerUIBundle.presets.apis,SwaggerUIStandalonePreset],
                plugins: [SwaggerUIBundle.plugins.DownloadUrl],
                layout: 'StandaloneLayout',
            };
            
            // If Url is relative, append the host and port
            var oar = "/q/swagger-ui/oauth2-redirect.html";
            if(oar.startsWith("/")){
                oar = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + oar;
                ui.oauth2RedirectUrl = oar;
            }else if(oar !== "-"){
                ui.oauth2RedirectUrl = oar;
            }
            
            ui.initOAuth({
	clientId: 'ui',
	appName: 'User Management Swagger UI',
})
            
            window.ui = SwaggerUIBundle(ui)

            document.getElementsByClassName("link")[0].innerHTML = "<a href='/q/swagger-ui'><img src='logo.png' alt='OpenAPI UI (Powered by Quarkus 2.2.1.Final)' height='44' align='middle'></a>";
        }
    </script>
</body>

`

Expected behavior

Swagger UI console is rendered, with an option for OAuth authorization.

Actual behavior

Swagger UI console fails to render and gives JavaScript error

How to Reproduce?

No response

Output of uname -a or ver

Microsoft Windows [Version 10.0.19043.1165]

Output of java -version

openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)

Additional information

No response

@flynnk flynnk added the kind/bug Something isn't working label Sep 5, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 5, 2021

/cc @MikeEdgar, @phillip-kruger

@quarkus-bot quarkus-bot bot added area/swagger-ui env/windows Impacts Windows machines labels Sep 5, 2021
@phillip-kruger
Copy link
Member

Thanks ! This is already fixed in smallrye/smallrye-open-api#887 and will be pulled into Quarkus soon.

@quarkus-bot quarkus-bot bot added this to the 2.3 - main milestone Sep 8, 2021
@gsmet gsmet modified the milestones: 2.3.0.CR1, 2.2.4.Final Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/swagger-ui env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants