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

Add support for external OpenAPI docs #502

Merged
merged 1 commit into from
Mar 1, 2023

Conversation

juhaku
Copy link
Owner

@juhaku juhaku commented Mar 1, 2023

Add support for external OpenAPI docs aside from the utoipa::OpenApi struct. This commit adds necessary functionality to SwaggerUi to define external API docs as serde_json::Value,
which is supported in actix-web, axum and rocket.

 let swagger = SwaggerUi::new("/swagger-ui/{_:.*}")
     .external_url_unchecked("/api-docs/openapi.json", external_openapi);

 let swagger = SwaggerUi::new("/swagger-ui/{_:.*}")
     .external_urls_from_iter_unchecked([
         ("/api-docs/openapi.json", external_openapi),
         ("/api-docs/openapi2.json", external_openapi2)
     ]);

Fixes #293

Add support for external OpenAPI docs aside from the `utoipa::OpenApi`
struct. This commit adds necessary functionality to `SwaggerUi` to
define external API docs as `serde_json::Value`,
which is supported in `actix-web`, `axum` and `rocket`.
```rust
 let swagger = SwaggerUi::new("/swagger-ui/{_:.*}")
     .external_url_unchecked("/api-docs/openapi.json", external_openapi);

 let swagger = SwaggerUi::new("/swagger-ui/{_:.*}")
     .external_urls_from_iter_unchecked([
         ("/api-docs/openapi.json", external_openapi),
         ("/api-docs/openapi2.json", external_openapi2)
     ]);
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
1 participant