nori/document

OpenAPI Document (root object) for OpenAPI specifications.

This is the root object of an OpenAPI document.

Types

The root object of an OpenAPI document.

pub type Document {
  Document(
    openapi: @internal OpenApiVersion,
    info: info.Info,
    json_schema_dialect: option.Option(String),
    servers: List(server.Server),
    paths: option.Option(
      dict.Dict(String, reference.Ref(operation.PathItem)),
    ),
    webhooks: dict.Dict(String, reference.Ref(operation.PathItem)),
    components: option.Option(components.Components),
    security: List(dict.Dict(String, List(String))),
    tags: List(operation.Tag),
    external_docs: option.Option(schema.ExternalDocumentation),
    extensions: dict.Dict(String, json.Json),
  )
}

Constructors

  • Document(
      openapi: @internal OpenApiVersion,
      info: info.Info,
      json_schema_dialect: option.Option(String),
      servers: List(server.Server),
      paths: option.Option(
        dict.Dict(String, reference.Ref(operation.PathItem)),
      ),
      webhooks: dict.Dict(String, reference.Ref(operation.PathItem)),
      components: option.Option(components.Components),
      security: List(dict.Dict(String, List(String))),
      tags: List(operation.Tag),
      external_docs: option.Option(schema.ExternalDocumentation),
      extensions: dict.Dict(String, json.Json),
    )

    Arguments

    openapi

    This string MUST be the version number of the OpenAPI Specification that the OpenAPI document uses.

    info

    Provides metadata about the API.

    json_schema_dialect

    The default value for the $schema keyword within Schema Objects.

    servers

    An array of Server Objects, which provide connectivity information to a target server.

    paths

    The available paths and operations for the API.

    webhooks

    The incoming webhooks that may be received as part of this API.

    components

    An element to hold various schemas for the document.

    security

    A declaration of which security mechanisms can be used across the API.

    tags

    A list of tags used by the document with additional metadata.

    external_docs

    Additional external documentation.

    extensions

    Extension fields (x-*)

Values

pub fn add_path(
  doc: Document,
  path: String,
  item: operation.PathItem,
) -> Document

Adds a path to the document.

pub fn add_security(
  doc: Document,
  requirement: dict.Dict(String, List(String)),
) -> Document

Adds a security requirement to the document.

pub fn add_server(
  doc: Document,
  server: server.Server,
) -> Document

Adds a server to the document.

pub fn add_tag(doc: Document, tag: operation.Tag) -> Document

Adds a tag to the document.

pub fn add_webhook(
  doc: Document,
  name: String,
  path_item: operation.PathItem,
) -> Document

Adds a webhook to the document.

pub fn get_operation_ids(doc: Document) -> List(String)

Gets all operation IDs from the document.

pub fn is_3_1(doc: Document) -> Bool

Checks if the document uses OpenAPI 3.1.x.

pub fn new(
  openapi: @internal OpenApiVersion,
  info: info.Info,
) -> Document

Creates a minimal Document with required fields.

pub fn v3_1_0(title: String, api_version: String) -> Document

Creates a new OpenAPI 3.1.0 document.

pub fn v3_1_1(title: String, api_version: String) -> Document

Creates a new OpenAPI 3.1.1 document.

pub fn version_string(doc: Document) -> String

Gets the OpenAPI version as a string.

pub fn with_components(
  doc: Document,
  components: components.Components,
) -> Document

Sets the components on the document.

pub fn with_external_docs(
  doc: Document,
  external_docs: schema.ExternalDocumentation,
) -> Document

Sets the external docs on the document.

pub fn with_info(doc: Document, info: info.Info) -> Document

Sets the info on the document.

pub fn with_json_schema_dialect(
  doc: Document,
  dialect: String,
) -> Document

Sets the JSON Schema dialect on the document.

pub fn with_paths(
  doc: Document,
  paths: dict.Dict(String, reference.Ref(operation.PathItem)),
) -> Document

Sets the paths on the document.

pub fn with_servers(
  doc: Document,
  servers: List(server.Server),
) -> Document

Sets the servers on the document.

Search Document