AsyncApiSpex.Validator (async_api_spex v0.1.0)

Copy Markdown View Source

Checks a resolved AsyncAPI document against the rules this library relies on.

validate/1 resolves the document first, then returns :ok or {:error, messages}. Every message names the JSON path it concerns. Rules checked:

  1. asyncapi is "3.0.0" and info has a non-empty title and version.
  2. Every server has a non-empty host and protocol.
  3. Server, channel, operation, channel message, and parameter ids match ~r/\A[A-Za-z0-9_-]+\z/; component schemas and messages match ~r/\A[A-Za-z0-9_.-]+\z/.
  4. A channel's {name} address expressions equal its parameter keys; a nil address has no parameters.
  5. Every channel server reference resolves.
  6. Every operation action is send or receive, its channel reference resolves, and its message references are messages of that channel.
  7. Every component schema and message reference resolves.
  8. Every extension key starts with x-.

Summary

Functions

Validates a document, resolving it first.

Functions

validate(doc)

@spec validate(AsyncApiSpex.Document.t()) :: :ok | {:error, [String.t()]}

Validates a document, resolving it first.