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

♻️ Generate cleaner Swagger HTML #11072

Closed

Conversation

s-rigaud
Copy link
Contributor

@s-rigaud s-rigaud commented Feb 1, 2024

Previously generated Swagger HTML was a bit junky, I just tried to improve the result. This PR is purely HTML aesthetic 🎨

   <!-- OLD -->
    <!DOCTYPE html>
    <html>
    <head>
    <link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/swagger-ui.css">
    <link rel="shortcut icon" href="https://fastapi.tiangolo.com/img/favicon.png">
    <title>FastAPI - Swagger UI</title>
    </head>
    <body>
    <div id="swagger-ui">
    </div>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/swagger-ui-bundle.js"></script>
    <!-- `SwaggerUIBundle` is now available on the page -->
    <script>
    const ui = SwaggerUIBundle({
        url: '/openapi.json',
    "dom_id": "#swagger-ui",
"layout": "BaseLayout",
"deepLinking": true,
"showExtensions": true,
"showCommonExtensions": true,
oauth2RedirectUrl: window.location.origin + '/docs/oauth2-redirect',
    presets: [
        SwaggerUIBundle.presets.apis,
        SwaggerUIBundle.SwaggerUIStandalonePreset
        ],
    })
    </script>
    </body>
    </html>
<!-- NEW -->

    <!DOCTYPE html>
    <html>
        <head>
            <link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/swagger-ui.css">
            <link rel="shortcut icon" href="https://fastapi.tiangolo.com/img/favicon.png">
            <title>FastAPI - Swagger UI</title>
        </head>
        <body>
            <div id="swagger-ui">
            </div>
            <script src="https://cdn.jsdelivr.net/npm/[email protected]/swagger-ui-bundle.js"></script>
            <!-- `SwaggerUIBundle` is now available on the page -->
            <script>
                const ui = SwaggerUIBundle({
                    url: '/openapi.json',
                    "dom_id": "#swagger-ui",
                    "layout": "BaseLayout",
                    "deepLinking": true,
                    "showExtensions": true,
                    "showCommonExtensions": true,
                    oauth2RedirectUrl: window.location.origin + '/docs/oauth2-redirect',
                    presets: [
                        SwaggerUIBundle.presets.apis,
                        SwaggerUIBundle.SwaggerUIStandalonePreset
                    ],
                })
                
            </script>
        </body>
    </html>

Copy link
Contributor

@hasansezertasan hasansezertasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this one is more easy to read and understand but I am not sure if it's really necessary. I'll check it ASAP.

@s-rigaud s-rigaud force-pushed the generate-cleaner-openapi-html branch from 001ff4b to 3e20475 Compare February 1, 2024 16:12
Copy link
Contributor

@hasansezertasan hasansezertasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alejsdev alejsdev changed the title 🎨 Generate cleaner Swagger HTML ♻️ Generate cleaner Swagger HTML Feb 2, 2024
Copy link
Contributor

@yezz123 yezz123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻!

Copy link
Contributor

📝 Docs preview for commit 39475f7 at: https://1a2fa28c.fastapitiangolo.pages.dev

Modified Pages

@s-rigaud s-rigaud force-pushed the generate-cleaner-openapi-html branch from 39475f7 to 3e20475 Compare January 23, 2025 01:03
@s-rigaud s-rigaud closed this Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants