Pravda v0.6.0 Pravda View Source

Validates input and output according to an OpenAPI specs.

Usage:

Add the plug at the bottom of one or more pipelines in router.ex:

pipeline "api" do
  # ...
  plug Pravada.Plugs.Validate, specs: [ "some_spec.json" ]
end

Link to this section Summary

Functions

attempt_validate_response checks to see if we are going to attempt to validate a response before we send it out.

Call function we attempt to validate params, then body, then our response body. and we return based on if we allow invalid input/output and the validity of the content

Init function sets all default variables and compiles the spec and paths so it can be fast. at run time.

Returns the version of the currently loaded Pravda, in string format.

Link to this section Types

Link to this type

open_api_spec()

View Source
open_api_spec() :: map()
Link to this type

path_regex()

View Source
path_regex() :: {path(), Regex.t()}

Link to this section Functions

Link to this function

attempt_validate_response(conn, opts, matched_version, path, arg5)

View Source
attempt_validate_response(
  Plug.Conn.t(),
  map(),
  String.t(),
  {String.t(), String.t()},
  boolean()
) :: Plug.Conn.t()

attempt_validate_response checks to see if we are going to attempt to validate a response before we send it out.

Link to this function

call(conn, opts)

View Source
call(Conn.t(), Keyword.t()) :: Conn.t()

Call function we attempt to validate params, then body, then our response body. and we return based on if we allow invalid input/output and the validity of the content

Link to this function

closest_input_version(versions, match_version)

View Source
Link to this function

get_closest_input_schema_with_version(version, versions)

View Source

Init function sets all default variables and compiles the spec and paths so it can be fast. at run time.

Returns the version of the currently loaded Pravda, in string format.