View Source OpenAPI.Processor.Operation (OpenAPI Generator v0.1.0-rc.4)
Default plugin for formatting operations
This module also provides the Operation struct that is used by the renderer.
Link to this section Summary
Types
HTTP method
Request content types and their associated schemas
Request content types and their associated schema specs
Response status codes and their associated schemas
Response status codes and their associated schema specs
Processed operation data used by the renderer
Default Implementations
Create the contents of an @doc
string for the given operation
Collect request content types and their associated schemas
Cast the HTTP method to an atom
Collect response status codes and their associated schemas
Link to this section Types
@type method() :: :get | :put | :post | :delete | :options | :head | :patch | :trace
HTTP method
@type request_body() :: [ {content_type :: String.t(), schema :: OpenAPI.Processor.Type.t()} ]
Request content types and their associated schemas
@type request_body_unprocessed() :: [ {content_type :: String.t(), schema :: OpenAPI.Spec.Schema.t()} ]
Request content types and their associated schema specs
@type response_body() :: [ {status :: integer() | :default, schemas :: %{required(String.t()) => OpenAPI.Processor.Type.t()}} ]
Response status codes and their associated schemas
@type response_body_unprocessed() :: [ {status :: integer() | :default, schemas :: %{required(String.t()) => OpenAPI.Spec.Schema.t()}} ]
Response status codes and their associated schema specs
@type t() :: %OpenAPI.Processor.Operation{ docstring: String.t(), function_name: atom(), module_name: atom(), request_body: request_body(), request_method: atom(), request_path: String.t(), request_path_parameters: [OpenAPI.Processor.Operation.Param.t()], request_query_parameters: [OpenAPI.Processor.Operation.Param.t()], responses: response_body() }
Processed operation data used by the renderer
Link to this section Default Implementations
@spec docstring(OpenAPI.Processor.State.t(), OpenAPI.Spec.Path.Operation.t(), [ OpenAPI.Processor.Operation.Param.t() ]) :: String.t()
Create the contents of an @doc
string for the given operation
Default implementation of OpenAPI.Processor.operation_docstring/3
.
The docstring constructed by this function will contain a summary line provided by the operation
summary (if available) or the request method and path otherwise. It will incorporate the
operation description (if available) and link to any included external documentation. Finally,
all query parameters (which are part of the opts
argument) are documented.
@doc """
Summary of the operation or method and path
Description of the operation, which generally provides more information.
## Options
* `param`: query parameter description
## Resources
* [External Doc Description](link to external documentation)
"""
@spec request_body(OpenAPI.Processor.State.t(), OpenAPI.Spec.Path.Operation.t()) :: request_body_unprocessed()
Collect request content types and their associated schemas
Default implementation of OpenAPI.Processor.operation_request_body/2
.
@spec request_method(OpenAPI.Processor.State.t(), OpenAPI.Spec.Path.Operation.t()) :: method()
Cast the HTTP method to an atom
Default implementation of OpenAPI.Processor.operation_request_method/2
.
@spec response_body(OpenAPI.Processor.State.t(), OpenAPI.Spec.Path.Operation.t()) :: response_body_unprocessed()
Collect response status codes and their associated schemas
Default implementation of OpenAPI.Processor.operation_response_body/2
.
In this implementation, all schemas are returned regardless of content type. It is possible for the same status code to have multiple schemas, in which case the renderer should compose a union type for the response.