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
-
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), )Arguments
- content_type
-
The Content-Type for encoding a specific property.
- headers
-
Headers for this encoding.
- style
-
Style of the encoding.
- explode
-
When true, values of type array or object generate separate parameters.
- allow_reserved
-
Determines whether the parameter value should allow reserved characters.
- extensions
-
Extension fields (x-*)
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
-
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), )Arguments
- description
-
A brief description of the header.
- required
-
Determines whether this header is mandatory.
- deprecated
-
Specifies that a header is deprecated.
- allow_empty_value
-
Sets the ability to pass empty-valued headers.
- style
-
Style of the header serialization.
- explode
-
When true, values generate separate parameters.
- allow_reserved
-
Whether to allow reserved characters.
- schema
-
The schema defining the type of the header.
- example
-
Example of the header’s value.
- examples
-
Examples of the header’s value.
- content
-
Content map for the header.
- extensions
-
Extension fields (x-*)
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
-
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), )Arguments
- schema
-
The schema defining the content.
- example
-
Example of the media type.
- examples
-
Examples of the media type.
- encoding
-
Encoding information for the media type.
- extensions
-
Extension fields (x-*)
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
-
InPathPath parameters (e.g., /users/{id})
-
InQueryQuery parameters (e.g., ?limit=10)
-
InHeaderHeader parameters
-
InCookieCookie parameters
Describes how the parameter value will be serialized.
pub type ParameterStyle {
StyleSimple
StyleLabel
StyleMatrix
StyleForm
StyleSpaceDelimited
StylePipeDelimited
StyleDeepObject
}
Constructors
-
StyleSimpleSimple style (default for path and header)
-
StyleLabelLabel style for path parameters
-
StyleMatrixMatrix style for path parameters
-
StyleFormForm style (default for query and cookie)
-
StyleSpaceDelimitedSpace-delimited style for query parameters
-
StylePipeDelimitedPipe-delimited style for query parameters
-
StyleDeepObjectDeep object style for query parameters
Values
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 style_to_string(style: ParameterStyle) -> String
Converts a ParameterStyle to its string representation.