Module rapidoc

Source
Expand description

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

§Example

use rocket_autodocu::settings::UrlObject;
use rocket_autodocu::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§

ApiConfig
Used to configure api access.
GeneralConfig
A struct containing information about where and how the openapi.json files are served.
HideShowConfig
Used to configure what features to hide or show.
LayoutConfig
Used to customize the layout of the displayed docs.
NavConfig
A struct containing information about where and how the openapi.json files are served.
RapiDocConfig
A struct containing information about where and how the openapi.json files are served.
SlotsConfig
Config used to configure the slots. Each slot usually corresponds with one section. Each field can include any HTML tags.
UiConfig
A struct containing information about where and how the openapi.json files are served.

Enums§

ApiKeyLocation
Determines how you want to send the api-key.
DefaultSchemaTab
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.
FetchCredentials
A RequestCredentials dictionary value indicating whether the user agent should send cookies from the other domain in the case of cross-origin requests.
FontSize
Used to contol the font size of text in the rapi doc interface.
Layout
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’.
NavBgImageRepeat
Used to control the repeating of the background image in the nav bar.
NavBgImageSize
Used to control the size of the background image in the nav bar.
NavItemSpacing
Controls navigation item spacing
NavTagClick
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.
RenderStyle
Determines display of api-docs. Currently there are two modes supported. ‘read’ - more suitable for reading and ‘view’ more friendly for quick exploring
SchemaHideReadOnly
Read-only fields in request schemas is always hidden but are shown in response.
SchemaHideWriteOnly
Read-only fields in request schemas is always hidden but are shown in response.
SchemaStyle
Two different ways to display object-schemas in the responses and request bodies.
SortEndpointsBy
Used to control the sorting mechanism of endpoints in the rapi doc interface.
Theme
Used to control the theme of the rapi doc interface.

Functions§

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