Expand description

Contains the functions and structs required to display the RapiDoc UI.

Example

use rocket_okapi::settings::UrlObject;
use rocket_okapi::rapidoc::{make_rapidoc, RapiDocConfig, GeneralConfig};

fn get_rapi_docs() -> RapiDocConfig {
    RapiDocConfig {
        general: GeneralConfig {
            spec_urls: get_urls(), // this is the only required field
            ..Default::default()
        },
        ..Default::default()
    }
}

fn get_urls() -> Vec<UrlObject> {
    vec![
        UrlObject::new("Resource", "/my_resource/openapi.json"),
    ]
}

#[rocket::main]
async fn main() {
    rocket::build()
        .mount("/rapi-doc", make_rapidoc(&get_rapi_docs()))
        .launch()
        .await
        .unwrap();
}

Structs

Used to configure api access.

A struct containing information about where and how the openapi.json files are served.

Used to configure what features to hide or show.

Used to customize the layout of the displayed docs.

A struct containing information about where and how the openapi.json files are served.

A struct containing information about where and how the openapi.json files are served.

Config used to configure the slots. Each slot usually corresponds with one section. Each field can include any HTML tags.

A struct containing information about where and how the openapi.json files are served.

Enums

Determines how you want to send the api-key.

The schemas are displayed in two tabs - Model and Example. This option allows you to pick the default tab that you would like to be active.

A RequestCredentials dictionary value indicating whether the user agent should send cookies from the other domain in the case of cross-origin requests.

Used to contol the font size of text in the rapi doc interface.

Layout helps in placement of request/response sections. In column layout, request & response sections are placed one below the other, In row layout they are placed side by side. This attribute is applicable only when the device width is more than 768px and the render-style is ‘view’.

Used to control the repeating of the background image in the nav bar.

Used to control the size of the background image in the nav bar.

Controls navigation item spacing

Applies only to focused render-style. It determines the behavior of clicking on a Tag in navigation bar. It can either expand-collapse the tag or take you to the tag’s description page.

Determines display of api-docs. Currently there are two modes supported. ‘read’ - more suitable for reading and ‘view’ more friendly for quick exploring

Read-only fields in request schemas is always hidden but are shown in response.

Read-only fields in request schemas is always hidden but are shown in response.

Two different ways to display object-schemas in the responses and request bodies.

Used to control the sorting mechanism of endpoints in the rapi doc interface.

Used to control the theme of the rapi doc interface.

Functions

Transform the provided RapiDocConfig into a list of Routes that serve the RapiDoc ui.