open_api_spex v3.4.0 OpenApiSpex.OpenApi behaviour 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
Link to this type
t()
View Source
t()
View Source
t() :: %OpenApiSpex.OpenApi{
components: OpenApiSpex.Components.t() | nil,
extensions: %{optional(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
}
t() :: %OpenApiSpex.OpenApi{ components: OpenApiSpex.Components.t() | nil, extensions: %{optional(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 function
json_encoder() View Source
Link to this section Callbacks
Link to this callback
spec()
View Source
spec()
View Source
spec() :: t()
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