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.Dict(String, Schema),
    responses: dict.Dict(String, Ref(Response)),
    parameters: dict.Dict(String, Ref(Parameter)),
    request_bodies: dict.Dict(String, Ref(RequestBody)),
  )
}

Constructors

Contact information for the exposed API.

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

Constructors

This is the root object of the OpenAPI document.

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

Constructors

pub type Header {
  Header(
    description: option.Option(String),
    required: Bool,
    schema: Schema,
  )
}

Constructors

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.Option(String),
    description: option.Option(String),
    terms_of_service: option.Option(String),
    contact: option.Option(Contact),
    license: option.Option(Licence),
    version: String,
  )
}

Constructors

License information for the exposed API.

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

Constructors

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

pub type MediaType {
  MediaType(schema: option.Option(Ref(Schema)))
}

Constructors

Describes a single API operation on a path.

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

Constructors

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.Option(String),
    required: Bool,
    schema: Ref(Schema),
  )
  PathParameter(name: String, schema: Ref(Schema))
  HeaderParameter(
    name: String,
    description: option.Option(String),
    required: Bool,
    schema: Ref(Schema),
  )
  CookieParameter(
    name: String,
    description: option.Option(String),
    required: Bool,
    schema: Ref(Schema),
  )
}

Constructors

Describes the operations available on a single path.

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

Constructors

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

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

Constructors

Describes a single request body.

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

Constructors

Describes a single response from an API Operation

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

Constructors

Represents a decoded JSON schema.

Chosen to add metadata inline as it doesn’t belong on ref object https://json-schema.org/draft/2020-12/json-schema-validation#name-a-vocabulary-for-basic-meta

pub type Schema {
  Boolean(
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  Integer(
    multiple_of: option.Option(Int),
    maximum: option.Option(Int),
    exclusive_maximum: option.Option(Int),
    minimum: option.Option(Int),
    exclusive_minimum: option.Option(Int),
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  Number(
    multiple_of: option.Option(Int),
    maximum: option.Option(Int),
    exclusive_maximum: option.Option(Int),
    minimum: option.Option(Int),
    exclusive_minimum: option.Option(Int),
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  String(
    max_length: option.Option(Int),
    min_length: option.Option(Int),
    pattern: option.Option(String),
    format: option.Option(String),
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  Null(
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  Array(
    max_items: option.Option(Int),
    min_items: option.Option(Int),
    unique_items: Bool,
    items: Ref(Schema),
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  Object(
    properties: dict.Dict(String, Ref(Schema)),
    required: List(String),
    additional_properties: option.Option(Ref(Schema)),
    max_properties: option.Option(Int),
    min_properties: Int,
    nullable: Bool,
    title: option.Option(String),
    description: option.Option(String),
    deprecated: Bool,
  )
  AllOf(non_empty_list.NonEmptyList(Ref(Schema)))
  AnyOf(non_empty_list.NonEmptyList(Ref(Schema)))
  OneOf(non_empty_list.NonEmptyList(Ref(Schema)))
  AlwaysPasses
  AlwaysFails
}

Constructors

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.Option(String),
    variables: dict.Dict(String, ServerVariable),
  )
}

Constructors

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

pub type ServerVariable {
  ServerVariable(
    enum: option.Option(non_empty_list.NonEmptyList(String)),
    default: String,
    description: option.Option(String),
  )
}

Constructors

pub type Status {
  Default
  Status(Int)
}

Constructors

  • Default
  • Status(Int)

Values

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