Skip to main content

Component

Trait Component 

Source
pub trait Component: Sealed + Sized {
    const SECTION: Section;

    // Required method
    fn section(
        openapi: &OpenAPI,
    ) -> Option<&IndexMap<String, ReferenceOr<Self>>>;
}
Expand description

A type that $ref pointers can name.

Implemented for the nine #/components types and for PathItem. The type is what decides which section is searched, so a pointer into a different section is reported as ResolveError::SectionMismatch rather than silently missing.

Note that Callback is a transparent alias for IndexMap<String, PathItem> rather than a distinct type, so any value of that shape resolves as a callback. That is upstream’s design, not a choice this crate can undo.

This trait is sealed: it cannot be implemented outside this crate. That keeps Self::SECTION and Self::section in agreement, and it is what makes the blanket impls on ReferenceOr<T> and ReferenceOr<Box<T>> non-overlapping for good.

Required Associated Constants§

Source

const SECTION: Section

The section of the document holding values of this type.

Required Methods§

Source

fn section(openapi: &OpenAPI) -> Option<&IndexMap<String, ReferenceOr<Self>>>

Borrows that section, or None if the document omits it entirely.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Component for Callback

Source§

const SECTION: Section = Section::Callbacks

Source§

fn section(openapi: &OpenAPI) -> Option<&IndexMap<String, ReferenceOr<Self>>>

Source§

impl Component for Example

Source§

const SECTION: Section = Section::Examples

Source§

fn section(openapi: &OpenAPI) -> Option<&IndexMap<String, ReferenceOr<Self>>>

Source§

impl Component for Header

Source§

const SECTION: Section = Section::Headers

Source§

fn section(openapi: &OpenAPI) -> Option<&IndexMap<String, ReferenceOr<Self>>>

Source§

const SECTION: Section = Section::Links

Source§

fn section(openapi: &OpenAPI) -> Option<&IndexMap<String, ReferenceOr<Self>>>

Source§

impl Component for Parameter

Source§

const SECTION: Section = Section::Parameters

Source§

fn section(openapi: &OpenAPI) -> Option<&IndexMap<String, ReferenceOr<Self>>>

Source§

impl Component for PathItem

Source§

const SECTION: Section = Section::Paths

Source§

fn section(openapi: &OpenAPI) -> Option<&IndexMap<String, ReferenceOr<Self>>>

Source§

impl Component for RequestBody

Source§

const SECTION: Section = Section::RequestBodies

Source§

fn section(openapi: &OpenAPI) -> Option<&IndexMap<String, ReferenceOr<Self>>>

Source§

impl Component for Response

Source§

const SECTION: Section = Section::Responses

Source§

fn section(openapi: &OpenAPI) -> Option<&IndexMap<String, ReferenceOr<Self>>>

Source§

impl Component for Schema

Source§

const SECTION: Section = Section::Schemas

Source§

fn section(openapi: &OpenAPI) -> Option<&IndexMap<String, ReferenceOr<Self>>>

Source§

impl Component for SecurityScheme

Source§

const SECTION: Section = Section::SecuritySchemes

Source§

fn section(openapi: &OpenAPI) -> Option<&IndexMap<String, ReferenceOr<Self>>>

Implementors§