Docspring.RequestValidator (docspring v4.1.0)

Checks a request against API v2's request schemas (request_schemas.json, the schemas the API validates requests with) before it's sent, and says what the API would say about it. api_clients/validator_conformance checks that it agrees with the API.

Docspring.Connection adds it as a Tesla middleware (unless validate_requests: false), after the body is encoded as JSON. Each operation names itself in the request's opts (docspring_operation: "createSubmission"), and a request the API would reject returns {:error, %Docspring.ValidationError{}} without being sent.

Summary

Functions

The details for a request to an operation (createSubmission): its query params and the JSON body it sends

The details for data checked against schema at location ("body" or "query")

Functions

errors(operation_id, query, body)

@spec errors(String.t(), map(), any()) :: [Docspring.Model.ErrorDetail.t()]

The details for a request to an operation (createSubmission): its query params and the JSON body it sends

validate(schema, data, location)

@spec validate(map(), any(), String.t()) :: [Docspring.Model.ErrorDetail.t()]

The details for data checked against schema at location ("body" or "query")