Download the PHP package wunderwerkio/http-api-utils without Composer
On this page you can find all versions of the php package wunderwerkio/http-api-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wunderwerkio/http-api-utils
More information about wunderwerkio/http-api-utils
Files in wunderwerkio/http-api-utils
Package http-api-utils
Short Description Set of useful HTTP API utilities. Provides json schema validation and error handling.
License MIT
Informations about the package http-api-utils
HTTP-API Utils
This package provides useful utilities for use with HTTP-APIs of any kind.
For response generation the symfony/http-foundation
package is being used.
Install
Install this package via composer:
Features
HttpApiValidationTrait
The HttpApiValidationTrait
provides methods to validate a data structure against a [JSON Schema)(https://json-schema.org/).
The validation itself is done with the justinrainbow/json-schema
package.
Define the schema:
Depending on your input data, you can use different validation methods to suit your needs:
validateDataStructure
Accepts a reference to an object. This is meant to be used with results fromjson_decode
.validateArray
Accepts an array as the data to validate.validateJsonString
Accepts a JSON encoded string.
Example (with the schema from above):
For more information, check out the JSON Schema package: https://github.com/justinrainbow/json-schema.
All versions of http-api-utils with dependencies
symfony/http-foundation Version ^4 || ^5 || ^6 || ^7
wunderwerkio/jsonapi-error Version ^1.0