open_api_spex v3.4.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

Link to this type

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()]
}

Operation Object

Describes a single API operation on a path.

Link to this section Functions

Link to this function

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 params to the types defined by the schemas of the operation parameters and requestBody

Link to this function

from_plug(plug, opts) View Source
from_plug(module(), any()) :: t()

Constructs an Operation struct from plug module and opts

Link to this function

from_route(route) View Source
from_route(PathItem.route()) :: t()

Constructs an Operation struct from the plug and opts specified in the given route

Link to this function

parameter(name, location, type, description, opts \\ []) View Source

Shorthand for constructing a Parameter name, location, type, description and optional examples

Link to this function

request_body(description, media_type, schema_ref, opts \\ []) View Source

Shorthand for constructing a RequestBody with description, media_type, schema and optional examples

Link to this function

response(description, media_type, schema_ref, opts \\ []) View Source

Shorthand for constructing a Response with description, media_type, schema and optional examples

Link to this function

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 params against the schemas of the operation parameters and requestBody