View Source OpenApiSpex.Reference (open_api_spex v3.19.0)

Defines the OpenApiSpex.Reference.t type.

Link to this section Summary

Link to this section Types

@type t() :: %OpenApiSpex.Reference{"$ref": String.t()}

Reference Object

A simple object to allow referencing other components in the specification, internally and externally. The Reference Object is defined by JSON Reference and follows the same structure, behavior and rules.

Link to this section Functions

Link to this function

resolve_parameter(reference, parameters)

View Source
@spec resolve_parameter(t(), %{required(String.t()) => OpenApiSpex.Parameter.t()}) ::
  OpenApiSpex.Parameter.t() | nil
Link to this function

resolve_request_body(reference, request_bodies)

View Source
@spec resolve_request_body(t(), %{required(String.t()) => OpenApiSpex.RequestBody.t()}) ::
  OpenApiSpex.RequestBody.t() | nil
Link to this function

resolve_response(reference, responses)

View Source
@spec resolve_response(t(), %{required(String.t()) => OpenApiSpex.Response.t()}) ::
  OpenApiSpex.Response.t() | nil
Link to this function

resolve_schema(reference, schemas)

View Source
@spec resolve_schema(t(), OpenApiSpex.Components.schemas_map()) ::
  OpenApiSpex.Schema.t() | nil

Resolve a Reference to the Schema it refers to.

examples

Examples

iex> alias OpenApiSpex.{Reference, Schema}
...> schemas = %{"user" => %Schema{title: "user", type: :object}}
...> Reference.resolve_schema(%Reference{"$ref": "#/components/schemas/user"}, schemas)
%OpenApiSpex.Schema{type: :object, title: "user"}