Pravda v0.4.2 Pravda View Source

Documentation for Pravda.

Link to this section Summary

Functions

Compile Paths is the function used to take a list of spec files and compile them into a list of routes we can validate with.

phoenix_route_to_schema takes a connections current path location and method and outputs a url that will match an openapi schema base definition it uses the router to correctly resolve the name and order of path arguments

validate_body is used to validate the input body for a spec, for a specific method, path.

validate params takes in and validates headers, path, and query parameters against the spec

validate_response is used to validate the responses section for a spec, for a specific method, path, and status.

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

Link to this section Functions

Link to this function

compile_paths(raw_specs)

View Source
compile_paths(list()) :: map()

Compile Paths is the function used to take a list of spec files and compile them into a list of routes we can validate with.

Link to this function

phoenix_route_to_schema(conn, router)

View Source
phoenix_route_to_schema(Plug.Conn.t(), module()) ::
  {String.t(), String.t()} | {nil, nil}

phoenix_route_to_schema takes a connections current path location and method and outputs a url that will match an openapi schema base definition it uses the router to correctly resolve the name and order of path arguments

Link to this function

validate_body(schema, body_params)

View Source
validate_body(map(), map()) :: true | {false, map()}

validate_body is used to validate the input body for a spec, for a specific method, path.

Link to this function

validate_params(schema, headers, path_params, query_params)

View Source
validate_params(map(), map(), map(), map()) :: true | {false, map()}

validate params takes in and validates headers, path, and query parameters against the spec

Link to this function

validate_response(schema, status, resp_body)

View Source
validate_response(map(), String.t() | integer(), String.t()) ::
  true | {false, map()}

validate_response is used to validate the responses section for a spec, for a specific method, path, and status.

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