WardrikRest.OpenAPI.Schema (wardrik_rest v0.1.0-rc.1)

Copy Markdown

Turns OpenAPI 3.0 and 3.1 schemas into JSON Schema for WardrikRest.Spec.

  • A reference to #/components/schemas/NAME stays a reference, as %{"$ref" => "NAME"}. Other references within the document are followed; references to other files are left as any value.
  • Fields the API only returns (readOnly) are left out, with them in required.
  • Kept: type, enum, const, pattern, description, properties, required, items, additionalProperties, oneOf, anyOf and allOf. nullable and a "null" type are dropped, as a tool's arguments may leave a field out.

Summary

Functions

Returns schema, from document, as JSON Schema.

Follows node's reference within document, to a parameter, a request body or any other object. Returns node itself when it isn't a reference, and %{} when it can't be followed.

Returns the document's components/schemas as types, by name.

Functions

json(schema, document)

@spec json(map() | boolean(), map()) :: map()

Returns schema, from document, as JSON Schema.

resolve(node, document)

@spec resolve(map(), map()) :: map()

Follows node's reference within document, to a parameter, a request body or any other object. Returns node itself when it isn't a reference, and %{} when it can't be followed.

types(document)

@spec types(map()) :: %{required(String.t()) => map()}

Returns the document's components/schemas as types, by name.