View Source OpenAPI.Processor.Type (OpenAPI Generator v0.1.0-rc.0)
Link to this section Summary
Types
Literal values, as found in const
and enum
definitions
Basic type
Special cases of the string type
Internal representation of types
Unnatural types introduced by the generator
Functions
Create an internal type representation of the given schema
Create an internal type representation of the given schema
Link to this section Types
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
@spec from_schema( %OpenAPI.Processor.State{ implementation: term(), operations: term(), profile: term(), schema_refs_by_path: term(), schema_specs_by_ref: term(), schemas_by_ref: term(), spec: term() }, OpenAPI.Spec.Schema.t() ) :: {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.
@spec primitive_from_schema(OpenAPI.Spec.Schema.t()) :: t()
Create an internal type representation of the given schema
This function does not support objects or other schemas that would be stored in the processor
state. If a schema may contain such a reference, use from_schema/2
instead.
It is expected that this function is called in cases when the range of possible types are known to be limited, such as query or path parameters.