View Source AshJsonApi.OpenApi (ash_json_api v1.4.11)

Provides functions for generating schemas and operations for OpenApi definitions.

Add open_api_spex to your mix.exs deps for the required struct definitions.

Example

defmodule MyApp.OpenApi do
  alias OpenApiSpex.{OpenApi, Info, Server, Components}

  def spec do
    %OpenApi{
      info: %Info{
        title: "MyApp JSON API",
        version: "1.1"
      },
      servers: [
        Server.from_endpoint(MyAppWeb.Endpoint)
      ],
      paths: AshJsonApi.OpenApi.paths(MyApp.Api),
      tags: AshJsonApi.OpenApi.tags(MyApp.Api),
      components: %Components{
        responses: AshJsonApi.OpenApi.responses(),
        schemas: AshJsonApi.OpenApi.schemas(MyApp.Api)
      }
    }
  end
end

Summary

Functions

Link to this function

define_filter?(domains, resource)

View Source
Link to this function

paths(domains, all_domains, opts)

View Source
@spec paths(
  domain :: module() | [module()],
  module() | [module()],
  opts :: Keyword.t()
) ::
  OpenApiSpex.Paths.t()

Paths (routes) from the domain.

Link to this function

raw_filter_type(attribute_or_aggregate, resource)

View Source
Link to this function

resource_filter_fields_fields_only(resource)

View Source
@spec responses() :: OpenApiSpex.Components.responses_map()

Common responses to include in the API Spec.

@spec schemas(domain :: module() | [module()]) :: %{
  required(String.t()) => OpenApiSpex.Schema.t()
}

Resource schemas to include in the API spec.

Link to this function

spec(opts \\ [], conn \\ nil)

View Source
@spec tags(domain :: module() | [module()]) :: [OpenApiSpex.Tag.t()]

Tags based on resource names to include in the API spec

Link to this function

write_attributes(resource, arguments, action, route, format)

View Source
@spec write_attributes(
  resource :: module(),
  [Ash.Resource.Actions.Argument.t()],
  action :: term(),
  route :: term(),
  format :: content_type_format()
) :: %{required(atom()) => OpenApiSpex.Schema.t()}