nori/parameter

Parameter types for OpenAPI specifications.

Parameters can be in path, query, header, or cookie.

Types

Encoding object for a media type property.

pub type Encoding {
  Encoding(
    content_type: option.Option(String),
    headers: option.Option(
      dict.Dict(String, reference.Ref(Header)),
    ),
    style: option.Option(ParameterStyle),
    explode: option.Option(Bool),
    allow_reserved: option.Option(Bool),
    extensions: dict.Dict(String, json.Json),
  )
}

Constructors

Example object for a parameter.

pub type Example {
  Example(
    summary: option.Option(String),
    description: option.Option(String),
    value: option.Option(json.Json),
    external_value: option.Option(String),
    extensions: dict.Dict(String, json.Json),
  )
}

Constructors

  • Example(
      summary: option.Option(String),
      description: option.Option(String),
      value: option.Option(json.Json),
      external_value: option.Option(String),
      extensions: dict.Dict(String, json.Json),
    )

    Arguments

    summary

    Short description for the example.

    description

    Long description for the example.

    value

    Embedded literal example.

    external_value

    URL that points to the literal example.

    extensions

    Extension fields (x-*)

Header object (similar to Parameter but without location).

pub type Header {
  Header(
    description: option.Option(String),
    required: option.Option(Bool),
    deprecated: option.Option(Bool),
    allow_empty_value: option.Option(Bool),
    style: option.Option(ParameterStyle),
    explode: option.Option(Bool),
    allow_reserved: option.Option(Bool),
    schema: option.Option(reference.Ref(schema.Schema)),
    example: option.Option(json.Json),
    examples: option.Option(
      dict.Dict(String, reference.Ref(Example)),
    ),
    content: option.Option(dict.Dict(String, MediaType)),
    extensions: dict.Dict(String, json.Json),
  )
}

Constructors

Media type object (used in content).

pub type MediaType {
  MediaType(
    schema: option.Option(reference.Ref(schema.Schema)),
    example: option.Option(json.Json),
    examples: option.Option(
      dict.Dict(String, reference.Ref(Example)),
    ),
    encoding: option.Option(dict.Dict(String, Encoding)),
    extensions: dict.Dict(String, json.Json),
  )
}

Constructors

Describes a single operation parameter.

pub type Parameter {
  Parameter(
    name: String,
    in_: ParameterLocation,
    description: option.Option(String),
    required: option.Option(Bool),
    deprecated: option.Option(Bool),
    allow_empty_value: option.Option(Bool),
    style: option.Option(ParameterStyle),
    explode: option.Option(Bool),
    allow_reserved: option.Option(Bool),
    schema: option.Option(reference.Ref(schema.Schema)),
    example: option.Option(json.Json),
    examples: option.Option(
      dict.Dict(String, reference.Ref(Example)),
    ),
    content: option.Option(dict.Dict(String, MediaType)),
    extensions: dict.Dict(String, json.Json),
  )
}

Constructors

  • Parameter(
      name: String,
      in_: ParameterLocation,
      description: option.Option(String),
      required: option.Option(Bool),
      deprecated: option.Option(Bool),
      allow_empty_value: option.Option(Bool),
      style: option.Option(ParameterStyle),
      explode: option.Option(Bool),
      allow_reserved: option.Option(Bool),
      schema: option.Option(reference.Ref(schema.Schema)),
      example: option.Option(json.Json),
      examples: option.Option(
        dict.Dict(String, reference.Ref(Example)),
      ),
      content: option.Option(dict.Dict(String, MediaType)),
      extensions: dict.Dict(String, json.Json),
    )

    Arguments

    name

    The name of the parameter. Case-sensitive.

    in_

    The location of the parameter.

    description

    A brief description of the parameter.

    required

    Determines whether this parameter is mandatory. If the parameter location is “path”, this property is required and its value must be true.

    deprecated

    Specifies that a parameter is deprecated.

    allow_empty_value

    Sets the ability to pass empty-valued parameters.

    style

    Describes how the parameter value will be serialized.

    explode

    When this is true, parameter values of type array or object generate separate parameters for each value.

    allow_reserved

    Determines whether the parameter value should allow reserved characters.

    schema

    The schema defining the type used for the parameter.

    example

    Example of the parameter’s potential value.

    examples

    Examples of the parameter’s potential value.

    content

    A map containing the representations for the parameter.

    extensions

    Extension fields (x-*)

The location of the parameter.

pub type ParameterLocation {
  InPath
  InQuery
  InHeader
  InCookie
}

Constructors

  • InPath

    Path parameters (e.g., /users/{id})

  • InQuery

    Query parameters (e.g., ?limit=10)

  • InHeader

    Header parameters

  • InCookie

    Cookie parameters

Describes how the parameter value will be serialized.

pub type ParameterStyle {
  StyleSimple
  StyleLabel
  StyleMatrix
  StyleForm
  StyleSpaceDelimited
  StylePipeDelimited
  StyleDeepObject
}

Constructors

  • StyleSimple

    Simple style (default for path and header)

  • StyleLabel

    Label style for path parameters

  • StyleMatrix

    Matrix style for path parameters

  • StyleForm

    Form style (default for query and cookie)

  • StyleSpaceDelimited

    Space-delimited style for query parameters

  • StylePipeDelimited

    Pipe-delimited style for query parameters

  • StyleDeepObject

    Deep object style for query parameters

Values

pub fn cookie_param(name: String) -> Parameter

Creates a cookie parameter.

pub fn header_param(name: String) -> Parameter

Creates a header parameter.

pub fn location_to_string(location: ParameterLocation) -> String

Converts a ParameterLocation to its string representation.

pub fn new(name: String, in_: ParameterLocation) -> Parameter

Creates an empty Parameter with the required fields.

pub fn parse_location(
  s: String,
) -> Result(ParameterLocation, Nil)

Parses a location string into a ParameterLocation.

pub fn parse_style(s: String) -> Result(ParameterStyle, Nil)

Parses a style string into a ParameterStyle.

pub fn path_param(name: String) -> Parameter

Creates a path parameter (required by default).

pub fn query_param(name: String) -> Parameter

Creates a query parameter.

pub fn style_to_string(style: ParameterStyle) -> String

Converts a ParameterStyle to its string representation.

Search Document