|
8 | 8 | //! First, add the following lines to your `Cargo.toml` |
9 | 9 | //! ```toml |
10 | 10 | //! [dependencies] |
11 | | -//! rocket_okapi = "0.3" |
12 | | -//! schemars = "0.6" |
13 | | -//! okapi = { version = "0.3", features = ["derive_json_schema"] } |
| 11 | +//! rocket_okapi = "0.5" |
| 12 | +//! schemars = "0.7" |
| 13 | +//! okapi = { version = "0.5", features = ["derive_json_schema"] } |
14 | 14 | //! ``` |
15 | 15 | //! To add documentation to a set of endpoints, a couple of steps are required. The request and |
16 | 16 | //! response types of the endpoint must implement `JsonSchema`. Secondly, the function must be |
|
22 | 22 | //! ### Example |
23 | 23 | //! ```rust, no_run |
24 | 24 | //! #![feature(decl_macro, proc_macro_hygiene)] |
25 | | -//! |
| 25 | +//! |
26 | 26 | //! use rocket::get; |
27 | 27 | //! use rocket_contrib::json::Json; |
28 | 28 | //! use rocket_okapi::{openapi, routes_with_openapi, JsonSchema}; |
29 | 29 | //! use rocket_okapi::swagger_ui::{make_swagger_ui, SwaggerUIConfig}; |
30 | | -//! |
| 30 | +//! |
31 | 31 | //! #[derive(serde::Serialize, JsonSchema)] |
32 | 32 | //! struct Response { |
33 | 33 | //! reply: String, |
34 | 34 | //! } |
35 | | -//! |
| 35 | +//! |
36 | 36 | //! #[openapi] |
37 | 37 | //! #[get("/")] |
38 | 38 | //! fn my_controller() -> Json<Response> { |
|
43 | 43 | //! |
44 | 44 | //! fn get_docs() -> SwaggerUIConfig { |
45 | 45 | //! use rocket_okapi::swagger_ui::UrlObject; |
46 | | -//! |
| 46 | +//! |
47 | 47 | //! SwaggerUIConfig { |
48 | 48 | //! url: "/my_resource/openapi.json".to_string(), |
49 | 49 | //! urls: vec![UrlObject::new("My Resource", "/v1/company/openapi.json")], |
50 | 50 | //! } |
51 | 51 | //! } |
52 | | -//! |
| 52 | +//! |
53 | 53 | //! fn main() { |
54 | 54 | //! rocket::ignite() |
55 | 55 | //! .mount("/my_resource", routes_with_openapi![my_controller]) |
|
60 | 60 |
|
61 | 61 | mod error; |
62 | 62 |
|
63 | | -/// Contains the `Generator` struct, which you can use to manually control the way a struct is |
| 63 | +/// Contains the `Generator` struct, which you can use to manually control the way a struct is |
64 | 64 | /// represented in the documentation. |
65 | 65 | pub mod gen; |
66 | 66 | /// Contains several `Rocket` `Handler`s, which are used for serving the json files and the swagger |
|
0 commit comments