-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add redoc support for utoipa. (#720)
Create new utoipa-redoc create and add simple redoc implementation. Add redoc service support for actix-web, axum and rocket. Add new warp-todo-redoc example to demonstarte utoipa-redoc in standalone without pre-existing web framework integration. Add CI setup for utoipa-redoc.
- Loading branch information
Showing
29 changed files
with
1,085 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ jobs: | |
- utoipa | ||
- utoipa-gen | ||
- utoipa-swagger-ui | ||
- utoipa-redoc | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = [ | ||
"utoipa", | ||
"utoipa-gen", | ||
"utoipa-swagger-ui", | ||
] | ||
members = ["utoipa", "utoipa-gen", "utoipa-swagger-ui", "utoipa-redoc"] | ||
|
||
[workspace.metadata.publish] | ||
order = ["utoipa-gen", "utoipa", "utoipa-swagger-ui"] | ||
order = ["utoipa-gen", "utoipa", "utoipa-swagger-ui", "utoipa-redoc"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "todo-warp-redoc-with-file-config" | ||
description = "Simple warp todo example api with utoipa and utoipa-redoc" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "MIT" | ||
authors = ["Elli Example <example@example.com>"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
tokio = { version = "1", features = ["full"] } | ||
warp = "0.3" | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" | ||
env_logger = "0.10.0" | ||
log = "0.4" | ||
futures = "0.3" | ||
utoipa = { path = "../../utoipa" } | ||
utoipa-redoc = { path = "../../utoipa-redoc" } | ||
|
||
[workspace] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# todo-warp-redoc-with-file-config ~ utoipa with utoipa-redoc example | ||
|
||
This is a demo `warp` application with in-memory storage to manage Todo items. | ||
|
||
This example is more bare minimum compared to `todo-actix`, since similarly same macro syntax is | ||
supported, no matter the framework. | ||
|
||
|
||
This how `utoipa-redoc` can be used as standalone without pre-existing framework integration with additional | ||
file configuration for the Redoc UI. The configuration is applicable in any other `utoipa-redoc` setup as well. | ||
|
||
See the `build.rs` file that defines the Redoc config file and `redoc.json` where the [configuration options](https://redocly.com/docs/api-reference-docs/configuration/functionality/#configuration-options-for-api-docs) | ||
are defined. | ||
|
||
For security restricted endpoints the super secret API key is: `utoipa-rocks`. | ||
|
||
Just run command below to run the demo application and browse to `http://localhost:8080/redoc`. | ||
|
||
```bash | ||
cargo run | ||
``` | ||
|
||
If you want to see some logging, you may prepend the command with `RUST_LOG=debug` as shown below. | ||
|
||
```bash | ||
RUST_LOG=debug cargo run | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("cargo:rustc-env=UTOIPA_REDOC_CONFIG_FILE=redoc.json") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"disableSearch": true | ||
} |
Oops, something went wrong.