open_api_spex v3.2.0 OpenApiSpex.Operation View Source
Defines the OpenApiSpex.Operation.t
type.
Link to this section Summary
Functions
Cast params to the types defined by the schemas of the operation parameters and requestBody
Constructs an Operation struct from plug module and opts
Constructs an Operation struct from the plug and opts specified in the given route
Shorthand for constructing a Parameter name, location, type, description and optional examples
Shorthand for constructing a RequestBody with description, media_type, schema and optional examples
Shorthand for constructing a Response with description, media_type, schema and optional examples
Validate params against the schemas of the operation parameters and requestBody
Link to this section Types
t()
View Source
t() :: %OpenApiSpex.Operation{
callbacks: %{
optional(String.t()) => OpenApiSpex.Callback.t() | OpenApiSpex.Reference.t()
},
deprecated: boolean(),
description: String.t() | nil,
externalDocs: OpenApiSpex.ExternalDocumentation.t() | nil,
operationId: String.t() | nil,
parameters: [OpenApiSpex.Parameter.t() | OpenApiSpex.Reference.t()],
requestBody: OpenApiSpex.RequestBody.t() | OpenApiSpex.Reference.t() | nil,
responses: OpenApiSpex.Responses.t(),
security: [OpenApiSpex.SecurityRequirement.t()] | nil,
servers: [OpenApiSpex.Server.t()] | nil,
summary: String.t() | nil,
tags: [String.t()]
}
t() :: %OpenApiSpex.Operation{ callbacks: %{ optional(String.t()) => OpenApiSpex.Callback.t() | OpenApiSpex.Reference.t() }, deprecated: boolean(), description: String.t() | nil, externalDocs: OpenApiSpex.ExternalDocumentation.t() | nil, operationId: String.t() | nil, parameters: [OpenApiSpex.Parameter.t() | OpenApiSpex.Reference.t()], requestBody: OpenApiSpex.RequestBody.t() | OpenApiSpex.Reference.t() | nil, responses: OpenApiSpex.Responses.t(), security: [OpenApiSpex.SecurityRequirement.t()] | nil, servers: [OpenApiSpex.Server.t()] | nil, summary: String.t() | nil, tags: [String.t()] }
Describes a single API operation on a path.
Link to this section Functions
cast(operation, conn, content_type, schemas)
View Source
cast(OpenApiSpex.Operation.t(), Conn.t(), String.t() | nil, %{
optional(String.t()) => OpenApiSpex.Schema.t()
}) :: {:ok, Plug.Conn.t()} | {:error, String.t()}
cast(OpenApiSpex.Operation.t(), Conn.t(), String.t() | nil, %{ optional(String.t()) => OpenApiSpex.Schema.t() }) :: {:ok, Plug.Conn.t()} | {:error, String.t()}
Cast params to the types defined by the schemas of the operation parameters and requestBody
from_plug(plug, opts) View Source
Constructs an Operation struct from plug module and opts
from_route(route)
View Source
from_route(PathItem.route()) :: t()
from_route(PathItem.route()) :: t()
Constructs an Operation struct from the plug and opts specified in the given route
parameter(name, location, type, description, opts \\ [])
View Source
parameter(
atom(),
OpenApiSpex.Parameter.location(),
OpenApiSpex.Reference.t() | OpenApiSpex.Schema.t() | atom(),
String.t(),
keyword()
) :: OpenApiSpex.Parameter.t()
parameter( atom(), OpenApiSpex.Parameter.location(), OpenApiSpex.Reference.t() | OpenApiSpex.Schema.t() | atom(), String.t(), keyword() ) :: OpenApiSpex.Parameter.t()
Shorthand for constructing a Parameter name, location, type, description and optional examples
request_body(description, media_type, schema_ref, opts \\ [])
View Source
request_body(
String.t(),
String.t(),
OpenApiSpex.Schema.t() | OpenApiSpex.Reference.t() | module(),
keyword()
) :: OpenApiSpex.RequestBody.t()
request_body( String.t(), String.t(), OpenApiSpex.Schema.t() | OpenApiSpex.Reference.t() | module(), keyword() ) :: OpenApiSpex.RequestBody.t()
Shorthand for constructing a RequestBody with description, media_type, schema and optional examples
response(description, media_type, schema_ref, opts \\ [])
View Source
response(
String.t(),
String.t(),
OpenApiSpex.Schema.t() | OpenApiSpex.Reference.t() | module(),
keyword()
) :: OpenApiSpex.Response.t()
response( String.t(), String.t(), OpenApiSpex.Schema.t() | OpenApiSpex.Reference.t() | module(), keyword() ) :: OpenApiSpex.Response.t()
Shorthand for constructing a Response with description, media_type, schema and optional examples
validate(operation, conn, content_type, schemas)
View Source
validate(OpenApiSpex.Operation.t(), Conn.t(), String.t() | nil, %{
optional(String.t()) => OpenApiSpex.Schema.t()
}) :: :ok | {:error, String.t()}
validate(OpenApiSpex.Operation.t(), Conn.t(), String.t() | nil, %{ optional(String.t()) => OpenApiSpex.Schema.t() }) :: :ok | {:error, String.t()}
Validate params against the schemas of the operation parameters and requestBody