View Source OpenAPI.Renderer.Schema (OpenAPI Generator v0.1.0-rc.0)

Default implementation for callbacks related to rendering schemas

This module contains the default implementations for:

extra-fields

Extra Fields

It is sometimes useful for client libraries to store additional information on the structs defined by the API description. This kind of private information is supported using the output.extra_fields configuration. Each entry in the keyword list must use the name of the field as the atom key and the type as the value. Types can be any valid OpenAPI.Processor.Type.t/0.

Example:

config :oapi_generator, default: [
  output: [
    __info__: :map
  ]
]

This will result in a field info: map added to every schema typespec and :info added to every struct definition.

configuration

Configuration

All configuration offered by the functions in this module lives under the output key of the active configuration profile. For example (default values shown):

# config/config.exs

config :oapi_generator, default: [
  output: [
    extra_fields: []
  ]
]

Link to this section Summary

Functions

Render a schema, including typespecs, struct definition, and field function

Render a function __fields__/1 that returns information about schema field types

Render a single struct definition for all of the given schemas

Render the typespec(s) for all of the given schemas

Link to this section Functions

Render a schema, including typespecs, struct definition, and field function

Default implementation of OpenAPI.Renderer.render_schema/2.

This implementation operates on schemas that appear in multiple contexts. If a schema appears in exactly one context as the request or response body of a function, it will instead be rendered by an operation callback.

This function calls the following other callbacks and concatenates their results:

Link to this function

render_field_function(state, schemas)

View Source
@spec render_field_function(OpenAPI.Renderer.State.t(), [OpenAPI.Processor.Schema.t()]) ::
  Macro.t()

Render a function __fields__/1 that returns information about schema field types

Default implementation of OpenAPI.Renderer.render_schema_field_function/2.

This implementation renders a function spec and header with one clause for each schema type.

Link to this function

render_struct(state, schemas)

View Source

Render a single struct definition for all of the given schemas

Default implementation of OpenAPI.Renderer.render_schema_struct/2.

This implementation combines the fields of all schemas to create one struct. It also uses the output.extra_fields configuration to add additional fields to the struct for private use by the client library. See Extra Fields in this module's documentation.

Link to this function

render_types(state, schemas)

View Source

Render the typespec(s) for all of the given schemas

Default implementation of OpenAPI.Renderer.render_schema_types/2.

This implementation uses the output.extra_fields configuration to add additional fields to the struct for private use by the client library. See Extra Fields in this module's documentation.