OpenApiSpex.OpenApi behaviour (open_api_spex v3.10.0) View Source
Defines the OpenApiSpex.OpenApi.t type and the behaviour for application modules that
construct an OpenApiSpex.OpenApi.t at runtime.
Link to this section Summary
Callbacks
A spec/0 callback function is required for use with the OpenApiSpex.Plug.PutApiSpec plug.
Link to this section Types
Specs
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.
Link to this section Functions
Link to this section Callbacks
Specs
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