Skip to main content

ScalarConfig

Struct ScalarConfig 

Source
pub struct ScalarConfig {
Show 13 fields pub theme: ScalarTheme, pub dark_mode: bool, pub hide_search: bool, pub hide_dark_mode_toggle: bool, pub show_sidebar: bool, pub layout: ScalarLayout, pub hide_models: bool, pub hide_client_button: bool, pub document_download: DocumentDownload, pub show_developer_tools: DeveloperTools, pub agent_enabled: bool, pub mcp_enabled: bool, pub cdn_url: Option<String>,
}
Expand description

Scalar UI rendering options.

All fields default to the values the crate has shipped since the initial Scalar adoption — constructing ScalarConfig::default() and passing it to MountOpts::scalar is a no-op compared to omitting the call entirely.

§Example

use doxa::{ScalarConfig, ScalarLayout, ScalarTheme};

let cfg = ScalarConfig::default()
    .layout(ScalarLayout::Classic)
    .theme(ScalarTheme::Solarized)
    .dark_mode(false);

Fields§

§theme: ScalarTheme

Visual theme. Defaults to ScalarTheme::Default.

§dark_mode: bool

Initial dark mode state. Defaults to true. The user-facing toggle remains visible unless Self::hide_dark_mode_toggle is set.

§hide_search: bool

Hide the search box. Defaults to false.

§hide_dark_mode_toggle: bool

Hide the dark-mode toggle in the header. Defaults to false.

§show_sidebar: bool

Show the left sidebar. Defaults to true.

§layout: ScalarLayout

Page layout. Defaults to ScalarLayout::Modern (three-pane nav / description / playground).

§hide_models: bool

Hide the standalone “Models” / schemas index. Defaults to true — referenced schemas still render inline under each operation.

§hide_client_button: bool

Hide the “copy as curl/node/…” codegen button row. Defaults to true. The interactive try-it-out panel is unaffected.

§document_download: DocumentDownload

Format offered by the header “Download OpenAPI” button. Defaults to DocumentDownload::None — the spec is still reachable at the mounted JSON path.

§show_developer_tools: DeveloperTools

When the developer-tools drawer is exposed. Defaults to DeveloperTools::Never.

§agent_enabled: bool

Enable Scalar’s “Ask AI” assistant. Defaults to false. Scalar charges for production use of this feature; leaving it off keeps the docs UI free of upsell surface.

§mcp_enabled: bool

Enable Scalar’s “Generate MCP” integration. Defaults to false for the same reason as Self::agent_enabled.

§cdn_url: Option<String>

Override the Scalar CDN URL. None keeps the crate’s default (https://cdn.jsdelivr.net/npm/@scalar/api-reference). Useful for air-gapped deployments, CDN mirrors, or self-hosted Scalar bundles — set this to the URL of the @scalar/api-reference script the browser should load.

This field is skipped during JSON serialization — it is a server-side concern only (the URL is written into the HTML template, not handed to Scalar as configuration).

Implementations§

Source§

impl ScalarConfig

Source

pub fn theme(self, theme: ScalarTheme) -> Self

Override the visual theme.

Source

pub fn layout(self, layout: ScalarLayout) -> Self

Override the page layout.

Source

pub fn dark_mode(self, on: bool) -> Self

Set the initial dark mode state.

Source

pub fn hide_dark_mode_toggle(self, hide: bool) -> Self

Hide or show the dark-mode toggle.

Hide or show the search box.

Source

pub fn show_sidebar(self, show: bool) -> Self

Show or hide the left sidebar.

Source

pub fn hide_models(self, hide: bool) -> Self

Hide or show the standalone schemas index.

Source

pub fn hide_client_button(self, hide: bool) -> Self

Hide or show the codegen button row.

Source

pub fn document_download(self, format: DocumentDownload) -> Self

Configure the header download button format.

Source

pub fn show_developer_tools(self, when: DeveloperTools) -> Self

Configure when the developer-tools drawer is exposed.

Source

pub fn agent_enabled(self, on: bool) -> Self

Enable or disable Scalar’s “Ask AI” agent.

Source

pub fn mcp_enabled(self, on: bool) -> Self

Enable or disable Scalar’s “Generate MCP” integration.

Source

pub fn cdn_url(self, url: impl Into<String>) -> Self

Override the Scalar CDN URL. See Self::cdn_url for when to use this.

Trait Implementations§

Source§

impl Clone for ScalarConfig

Source§

fn clone(&self) -> ScalarConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScalarConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ScalarConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Serialize for ScalarConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,