oas

Types

Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object.

pub type Components {
  Components(
    schemas: Dict(String, Schema),
    responses: Dict(String, Ref(Response)),
    parameters: Dict(String, Ref(Parameter)),
    request_bodies: Dict(String, Ref(RequestBody)),
  )
}

Constructors

  • Components(
      schemas: Dict(String, Schema),
      responses: Dict(String, Ref(Response)),
      parameters: Dict(String, Ref(Parameter)),
      request_bodies: Dict(String, Ref(RequestBody)),
    )

Contact information for the exposed API.

pub type Contact {
  Contact(
    name: Option(String),
    url: Option(String),
    email: Option(String),
  )
}

Constructors

  • Contact(
      name: Option(String),
      url: Option(String),
      email: Option(String),
    )

This is the root object of the OpenAPI document.

pub type Document {
  Document(
    openapi: String,
    info: Info,
    json_schema_dialect: Option(String),
    servers: List(Server),
    paths: Dict(String, PathItem),
    components: Components,
  )
}

Constructors

  • Document(
      openapi: String,
      info: Info,
      json_schema_dialect: Option(String),
      servers: List(Server),
      paths: Dict(String, PathItem),
      components: Components,
    )
pub type Header {
  Header(
    description: Option(String),
    required: Bool,
    schema: Schema,
  )
}

Constructors

  • Header(
      description: Option(String),
      required: Bool,
      schema: Schema,
    )

The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience.

pub type Info {
  Info(
    title: String,
    summary: Option(String),
    description: Option(String),
    terms_of_service: Option(String),
    contact: Option(Contact),
    license: Option(Licence),
    version: String,
  )
}

Constructors

  • Info(
      title: String,
      summary: Option(String),
      description: Option(String),
      terms_of_service: Option(String),
      contact: Option(Contact),
      license: Option(Licence),
      version: String,
    )

License information for the exposed API.

pub type Licence {
  Licence(
    name: String,
    identifier: Option(String),
    url: Option(String),
  )
}

Constructors

  • Licence(
      name: String,
      identifier: Option(String),
      url: Option(String),
    )

Each Media Type Object provides schema and examples for the media type identified by its key.

pub type MediaType {
  MediaType(schema: Ref(Schema))
}

Constructors

  • MediaType(schema: Ref(Schema))

Describes a single API operation on a path.

pub type Operation {
  Operation(
    tags: List(String),
    summary: Option(String),
    description: Option(String),
    operation_id: String,
    parameters: List(Ref(Parameter)),
    request_body: Option(Ref(RequestBody)),
    responses: Dict(Status, Ref(Response)),
  )
}

Constructors

  • Operation(
      tags: List(String),
      summary: Option(String),
      description: Option(String),
      operation_id: String,
      parameters: List(Ref(Parameter)),
      request_body: Option(Ref(RequestBody)),
      responses: Dict(Status, Ref(Response)),
    )

Describes a single operation parameter.

There are four possible parameter locations specified by the in field: path, query, header and cookie. A unique parameter is defined by a combination of a name and location.

pub type Parameter {
  QueryParameter(
    name: String,
    description: Option(String),
    required: Bool,
    schema: Ref(Schema),
  )
  PathParameter(name: String, schema: Ref(Schema))
  HeaderParameter(
    name: String,
    description: Option(String),
    required: Bool,
    schema: Ref(Schema),
  )
  CookieParameter(
    name: String,
    description: Option(String),
    required: Bool,
    schema: Ref(Schema),
  )
}

Constructors

  • QueryParameter(
      name: String,
      description: Option(String),
      required: Bool,
      schema: Ref(Schema),
    )
  • PathParameter(name: String, schema: Ref(Schema))
  • HeaderParameter(
      name: String,
      description: Option(String),
      required: Bool,
      schema: Ref(Schema),
    )
  • CookieParameter(
      name: String,
      description: Option(String),
      required: Bool,
      schema: Ref(Schema),
    )

Describes the operations available on a single path.

pub type PathItem {
  PathItem(
    summary: Option(String),
    description: Option(String),
    parameters: List(Ref(Parameter)),
    operations: List(#(http.Method, Operation)),
  )
}

Constructors

  • PathItem(
      summary: Option(String),
      description: Option(String),
      parameters: List(Ref(Parameter)),
      operations: List(#(http.Method, Operation)),
    )

Node in the Specification that might be represented by a reference.

pub type Ref(t) {
  Ref(
    ref: String,
    summary: Option(String),
    description: Option(String),
  )
  Inline(value: t)
}

Constructors

  • Ref(
      ref: String,
      summary: Option(String),
      description: Option(String),
    )
  • Inline(value: t)

Describes a single request body.

pub type RequestBody {
  RequestBody(
    description: Option(String),
    content: Dict(String, MediaType),
    required: Bool,
  )
}

Constructors

  • RequestBody(
      description: Option(String),
      content: Dict(String, MediaType),
      required: Bool,
    )

Describes a single response from an API Operation

pub type Response {
  Response(
    description: Option(String),
    headers: Dict(String, Ref(Header)),
    content: Dict(String, MediaType),
  )
}

Constructors

  • Response(
      description: Option(String),
      headers: Dict(String, Ref(Header)),
      content: Dict(String, MediaType),
    )

Represents a decoded JSON schema.

pub type Schema {
  Boolean
  Integer
  Number
  String
  Array(Ref(Schema))
  Object(properties: Dict(String, Ref(Schema)))
  AllOf(List(Ref(Dict(String, Ref(Schema)))))
  AnyOf(List(Ref(Schema)))
  OneOf(List(Ref(Schema)))
}

Constructors

  • Boolean
  • Integer
  • Number
  • String
  • Array(Ref(Schema))
  • Object(properties: Dict(String, Ref(Schema)))
  • AllOf(List(Ref(Dict(String, Ref(Schema)))))
  • AnyOf(List(Ref(Schema)))
  • OneOf(List(Ref(Schema)))
pub type Segment {
  FixedSegment(content: String)
  MatchSegment(name: String, schema: Schema)
}

Constructors

  • FixedSegment(content: String)
  • MatchSegment(name: String, schema: Schema)

An object representing a Server.

pub type Server {
  Server(
    url: String,
    description: Option(String),
    variables: Dict(String, ServerVariable),
  )
}

Constructors

  • Server(
      url: String,
      description: Option(String),
      variables: Dict(String, ServerVariable),
    )

An object representing a Server Variable for server URL template substitution.

pub type ServerVariable {
  ServerVariable(
    enum: List(String),
    default: String,
    description: Option(String),
  )
}

Constructors

  • ServerVariable(
      enum: List(String),
      default: String,
      description: Option(String),
    )
pub type Status {
  Default
  Status(Int)
}

Constructors

  • Default
  • Status(Int)

Functions

pub fn decoder(
  top: Dynamic,
) -> Result(Document, List(DecodeError))
pub fn fetch_parameter(
  ref: Ref(a),
  parameters: Dict(String, Ref(a)),
) -> a
pub fn fetch_request_body(
  ref: Ref(a),
  request_bodies: Dict(String, Ref(a)),
) -> a
pub fn fetch_response(
  ref: Ref(a),
  responses: Dict(String, Ref(a)),
) -> a
pub fn fetch_schema(ref: Ref(a), schemas: Dict(String, a)) -> a
pub fn gather_match(
  pattern: String,
  parameters: List(Parameter),
  components: Components,
) -> Result(List(Segment), Nil)
pub fn query_parameters(
  parameters: List(Parameter),
) -> List(#(String, Bool, Ref(Schema)))
Search Document