Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix openapi serialized twice when Rapidoc is served with Rocket #987

Merged
merged 1 commit into from
Aug 11, 2024

Conversation

Rauks
Copy link
Contributor

@Rauks Rauks commented Aug 9, 2024

Hello,

When Rocket serves a Rapidoc built using with_openapi, the served openapi.json is the result of an ApiDoc serialized twice.

rocket::build()
    .mount(
        "/",
        RapiDoc::with_openapi("/api-docs/openapi.json", ApiDoc::openapi()).path("/rapidoc"),
    )

As a result, Rapidoc fails to load the spec:

image

Inspecting the request response for /api-docs/openapi.json shows a "string of a json":

image

This PR is a fix proposal that resolves the double serialization.
After the fix, the spec now loads correctly and the /api-docs/openapi.json request response inspection shows "just a json":

image

image

Copy link
Owner

@juhaku juhaku left a comment

Choose a reason for hiding this comment

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

Thanks for the catch 👍

@juhaku juhaku merged commit 2406c75 into juhaku:master Aug 11, 2024
8 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants