View Source OpenApiSpex.OpenApi behaviour (open_api_spex v3.21.0)
Defines the OpenApiSpex.OpenApi.t
type and the behaviour for application modules that
construct an OpenApiSpex.OpenApi.t
at runtime.
Summary
Callbacks
A spec/0 callback function is required for use with the OpenApiSpex.Plug.PutApiSpec
plug.
Types
@type t() :: %OpenApiSpex.OpenApi{ components: OpenApiSpex.Components.t() | nil, extensions: %{required(String.t()) => any()} | nil, externalDocs: OpenApiSpex.ExternalDocumentation.t() | nil, info: OpenApiSpex.Info.t(), openapi: String.t(), paths: OpenApiSpex.Paths.t(), security: [OpenApiSpex.SecurityRequirement.t()] | nil, servers: [OpenApiSpex.Server.t()] | nil, tags: [OpenApiSpex.Tag.t()] | nil }
This is the root document object of the OpenAPI document.
Callbacks
@callback spec() :: t()
A spec/0 callback function is required for use with the OpenApiSpex.Plug.PutApiSpec
plug.
Example
@impl OpenApiSpex.OpenApi
def spec do
%OpenApi{
servers: [
# Populate the Server info from a phoenix endpoint
Server.from_endpoint(MyAppWeb.Endpoint)
],
info: %Info{
title: "My App",
version: "1.0"
},
# populate the paths from a phoenix router
paths: Paths.from_router(MyAppWeb.Router)
}
|> OpenApiSpex.resolve_schema_modules() # discover request/response schemas from path specs
end