View Source OpenAPI.Processor.State (OpenAPI Generator v0.1.0-rc.0)

State of the process phase of code generation

This struct is created at the beginning of the process phase using data from the overall generator OpenAPI.State. It has the following fields:

  • implementation: Module configured as the implementation of the processor (defaults to OpenAPI.Processor). Callbacks must use this field when calling other process callbacks.
  • operations: Cumulative list of OpenAPI.Processor.Operation.t/0 structs identified and processed so far.
  • profile: Name of the active configuration profile. Callbacks must use this field when looking up configuration from the application environment.
  • schema_specs_by_ref: Cumulative map of raw schema specifications keyed by the internal refs used to refer to them in types.
  • schema_refs_by_path: Cumulative map of internal refs used to refer to schemas keyed by the original paths where they could be found in the spec files.
  • schemas_by_ref: Cumulative map of processed OpenAPI.Processor.Schema.t/0 structs keyed by the internal refs used to refer to them in types, as they are processed.
  • spec: The original parsed OpenAPI description.

All of this data is managed by the code generator, and it is unlikely that a callback would need to transform this struct directly.

Link to this section Summary

Functions

Get a schema reference by the last ref file/path

Add a schema spec to the processor state and generate a reference for it

Link to this section Types

@type t() :: %OpenAPI.Processor.State{
  implementation: module(),
  operations: [OpenAPI.Processor.Operation.t()],
  profile: atom(),
  schema_refs_by_path: %{required(term()) => reference()},
  schema_specs_by_ref: %{required(reference()) => OpenAPI.Spec.Schema.t()},
  schemas_by_ref: %{required(reference()) => OpenAPI.Processor.Schema.t()},
  spec: OpenAPI.Spec.t()
}

Link to this section Functions

Link to this function

get_schema_ref_by_path(state, schema_spec)

View Source
@spec get_schema_ref_by_path(t(), OpenAPI.Spec.Schema.t()) :: reference() | nil

Get a schema reference by the last ref file/path

Link to this function

put_schema_spec(state, schema_spec)

View Source
@spec put_schema_spec(t(), OpenAPI.Spec.Schema.t()) :: {t(), reference()}

Add a schema spec to the processor state and generate a reference for it