oasgen_core

Struct OpenAPI

Source
pub struct OpenAPI {
    pub openapi: String,
    pub info: Info,
    pub servers: Vec<Server>,
    pub paths: Paths,
    pub components: Components,
    pub security: Vec<IndexMap<String, Vec<String>>>,
    pub tags: Vec<Tag>,
    pub external_docs: Option<ExternalDocumentation>,
    pub extensions: IndexMap<String, Value>,
}

Fields§

§openapi: String

REQUIRED. This string MUST be the semantic version number of the OpenAPI Specification version that the OpenAPI document uses. The openapi field SHOULD be used by tooling specifications and clients to interpret the OpenAPI document. This is not related to the API info.version string.

§info: Info

REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required.

§servers: Vec<Server>

An array of Server Objects, which provide connectivity information to a target server. If the servers property is not provided, or is an empty array, the default value would be a Server Object with a url value of /.

§paths: Paths

REQUIRED. The available paths and operations for the API.

§components: Components

An element to hold various schemas for the specification.

§security: Vec<IndexMap<String, Vec<String>>>

A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition. Global security settings may be overridden on a per-path basis.

§tags: Vec<Tag>

A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the Operation Object must be declared. The tags that are not declared MAY be organized randomly or based on the tool’s logic. Each tag name in the list MUST be unique.

§external_docs: Option<ExternalDocumentation>

Additional external documentation.

§extensions: IndexMap<String, Value>

Inline extensions to this object.

Implementations§

Source§

impl OpenAPI

Source

pub fn operations( &self, ) -> impl Iterator<Item = (&str, &str, &Operation, &PathItem)>

Iterates through all Operations in this API.

The iterated items are tuples of (&str, &str, &Operation, &PathItem) containing the path, method, and the operation.

Path items containing $refs are skipped.

Source

pub fn operations_mut( &mut self, ) -> impl Iterator<Item = (&str, &str, &mut Operation)>

Source

pub fn get_operation_mut( &mut self, operation_id: &str, ) -> Option<&mut Operation>

Source

pub fn get_operation( &self, operation_id: &str, ) -> Option<(&Operation, &PathItem)>

Source

pub fn merge(self, other: OpenAPI) -> Result<OpenAPI, MergeError>

Merge another OpenAPI document into this one, keeping original schemas on conflict. a.merge(b) will have all schemas from a and b, but keep a for any duplicates.

Source

pub fn merge_overwrite(self, other: OpenAPI) -> Result<OpenAPI, MergeError>

Merge another OpenAPI document into this one, replacing any duplicate schemas. a.merge_overwrite(b) will have all schemas from a and b, but keep b for any duplicates.

Methods from Deref<Target = Components>§

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Clone for OpenAPI

Source§

fn clone(&self) -> OpenAPI

Returns a copy 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 OpenAPI

Source§

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

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

impl Default for OpenAPI

Source§

fn default() -> OpenAPI

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

impl Deref for OpenAPI

Source§

type Target = Components

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<OpenAPI as Deref>::Target

Dereferences the value.
Source§

impl DerefMut for OpenAPI

Source§

fn deref_mut(&mut self) -> &mut <OpenAPI as Deref>::Target

Mutably dereferences the value.
Source§

impl<'de> Deserialize<'de> for OpenAPI

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<OpenAPI, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for OpenAPI

Source§

fn eq(&self, other: &OpenAPI) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for OpenAPI

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for OpenAPI

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, dst: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,