GithubHelp home page GithubHelp logo

dongilbert / laravel-openapi-validation-middleware Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 8 KB

Middleware for Laravel that will validate requests & responses according to your OpenAPI description document.

PHP 100.00%

laravel-openapi-validation-middleware's Introduction

OpenAPI Validation Middleware for Laravel

Middleware for Laravel that will validate requests & responses according to your OpenAPI description document.

Influenced by hkarlstrom's OpenAPI Validation Middlware that covers PSR-7 & PSR-15 requests. Sadly, Laravel middleware's are not compatible with either of those PSRs, so this package was required.

Compatibility

  • Laravel 5.7 | 5.8
  • PHP 7.2

Installation

Installation via composer is recommended. The Laravel Service provider will be auto-registered. You must also publish the configuration file and update the

composer require treblig/laravel-openapi-validation-middleware

After composer installation, there will be a new openapi middleware group available to your routes. You may add this middleware group to your routes following standard Laravel prodedures.

use Illuminate\Support\Route;

Route::middleware('openapi')->group(function ($router) {
    $router->get('/users/{user}', 'OpenAPIUserController');
});

Route::get('/users/{user}', 'OpenAPIUserController')
    ->middleware('openapi');

Configuration

Publish the package configuration file via:

php artisan vendor:publish --provider="Treblig\OpenAPIValidationMiddleware\ServiceProvider"

To leverage this package you must set the document_path config value. This can be either a local file path or remote HTTP resource link.

By default, both requests and responses are subject to the validation check. You can change this behavior in the openapi.php configuration file.

laravel-openapi-validation-middleware's People

Contributors

dongilbert avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.