View Source OpenAPI.Processor.Type (OpenAPI Generator v0.1.1)

Link to this section Summary

Types

Literal values, as found in const and enum definitions

Basic type

Special cases of the string type

t()

Internal representation of types

Unnatural types introduced by the generator

Functions

Create an internal type representation of the given schema

Link to this section Types

@type literal() :: binary() | boolean() | number() | nil

Literal values, as found in const and enum definitions

@type primitive() ::
  :boolean | :integer | :number | {:string, string_format()} | :null

Basic type

These types represent a subset of the six primitive values defined by JSON schema (omitting object and array, which are represented in t/0.) Note that both integer and number are acceptable types, with the latter covering both integer and decimal numbers.

@type string_format() ::
  :generic
  | :binary
  | :date
  | :date_time
  | :duration
  | :email
  | :hostname
  | :idn_email
  | :idn_hostname
  | :iri
  | :iri_reference
  | :ipv4
  | :ipv6
  | :json_pointer
  | :password
  | :regex
  | :relative_json_pointer
  | :time
  | :uri
  | :uri_reference
  | :uri_template
  | :uuid

Special cases of the string type

binary represents binary data that may be encoded, while generic represents a generic string without a formatting constraint.

@type t() ::
  primitive()
  | unnatural()
  | {:array, t()}
  | {:const, literal()}
  | {:enum, [literal()]}
  | {:union, [t()]}
  | reference()

Internal representation of types

In addition to the primitive/0 types, values can be constants or enums defined by literal/0 values. They can also be arrays or objects, as well as the union of multiple type definitions. If a value is nullable, it will be expressed as the union with :null.

Elixir references (reference/0) represent schemas stored in the processor State.

@type unnatural() :: :any | :map

Unnatural types introduced by the generator

These types may be introduced in extra fields or when referenced schemas are ignored.

Link to this section Functions

Link to this function

from_schema(state, schema)

View Source
@spec from_schema(
  %OpenAPI.Processor.State{
    implementation: term(),
    operations: term(),
    profile: term(),
    schema_refs_by_path: term(),
    schema_specs_by_path: term(),
    schema_specs_by_ref: term(),
    schemas_by_ref: term(),
    spec: term()
  },
  OpenAPI.Spec.Schema.t() | OpenAPI.Spec.ref()
) :: {OpenAPI.Processor.State.t(), t()}

Create an internal type representation of the given schema

This function supports referencing object schemas in the processor state. As a result, if it encounters an object schema as a sub-field of the given schema, it will potentially modify the processor state in order to stash a new reference.

Link to this function

reduce(type, accumulator, callback)

View Source
@spec reduce(t(), acc, (t(), acc -> acc)) :: acc when acc: any()