Download the PHP package adrenalinkin/swagger-resolver-bundle without Composer
On this page you can find all versions of the php package adrenalinkin/swagger-resolver-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download adrenalinkin/swagger-resolver-bundle
More information about adrenalinkin/swagger-resolver-bundle
Files in adrenalinkin/swagger-resolver-bundle
Package swagger-resolver-bundle
Short Description Provides possibility for validate data according to Swagger documentation
License MIT
Informations about the package swagger-resolver-bundle
Swagger Resolver Bundle
Feel free to connect with me by email or in Telegram.
Usage example on GitHub Gist
Introduction
Bundle provides possibility for validate data according to the Swagger 2 documentation. You describe your API documentation by Swagger and provides verification of data for compliance with the described requirements. When documentation has been updated then verification will be updated too, all in one place!
Documentation is cached through the standard Symfony Warmers mechanism.
In debug mode, the cache automatically warms up if you change the file containing the description of the documentation.
Note: as result bundle returns SwaggerResolver object - extension for the
OptionsResolver.
In this way you get full control over created resolver.
Attention: remember, when you change generated SwaggerResolver object you risk getting
divergence with actual documentation.
Integrations
Bundle provides integration with NelmioApiDocBundle,
supports configuration loading by swagger-php and also supports
loading directly from the json or yaml(yml) configuration file.
When used default bundle configuration then swagger documentation will be load in most optimal available way.
Loaders priority:
NelmioApiDocBundle- do not require any additional configuration.swagger-php- scansrc/directory by default. Usesswagger_php.scanandswagger_php.excludeparameters.json- looking forweb/swagger.jsonby default. Usesconfiguration_fileparameter.
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
is command requires you to have Composer install globally.
Step 2: Enable the Bundle
Then, enable the bundle by updating your app/AppKernel.php file to enable the bundle:
Configuration
To start using bundle you don't need to define some additional configuration. All parameters have values by default:
Usage
Step 1: Swagger documentation preparation
Swagger documentation preparation differ according to used tools of your project.
NelmioApiDocBundle
If your project has NelmioApiDocBundle connected, then no additional configuration is required.
swagger-php
In the absence of NelmioApiDocBundle, the bundle will degrade to the configuration
loading by swagger-php annotations. In this case, by default, will be used src/ directory to scan.
To optimize scanning process you can describe directories in the configuration:
JSON
In the absence of NelmioApiDocBundle and swagger-php, the bundle will degrade to the configuration
loading by json file. In this case, by default, will be used web/swagger.json file.
Also, you can set custom path to the json configuration:
YAML or (yml)
In the absence of NelmioApiDocBundle and swagger-php, but available
configuration file in the yaml or yml format you need to define path to that file:
Custom
If you need to use custom configuration loader you should implement custom loading process in the class, which implements SwaggerConfigurationLoaderInterface interface. After that you need to define name of that service in the configuration:
Step 2: Data validation
Validation for model
Validation for request
Advanced
Custom validator
Bundle validates the data through the validator system.
List of all validators, you can find out by going to the Validator folder.
All validators registered as tagging services. To create your own validator it is enough to create class,
which implements SwaggerValidatorInterface and then
register it under the tag linkin_swagger_resolver.validator.
Custom normalizer
Bundle validates the data through the normalizer system.
List of all normalizers, you can find out by going to the Normalizer folder.
All normalizers registered as tagging services. To create your own normalizer it is enough to create class,
which implements SwaggerNormalizerInterface and then
register it under the tag linkin_swagger_resolver.normalizer.
Running the tests and static analysis tools
Download the project:
Follow this instruction for set up simple docker container.
Install composer dependencies:
For run the test suite:
For run the PHP-CS-Fixer:
For run the composer-normalize:
License
All versions of swagger-resolver-bundle with dependencies
ext-json Version *
exsyst/swagger Version ^0.4
symfony/config Version ^3.4 || ^4.0 || ^5.0
symfony/dependency-injection Version ^3.4 || ^4.0 || ^5.0
symfony/finder Version ^3.4 || ^4.0 || ^5.0
symfony/http-foundation Version ^3.4 || ^4.0 || ^5.0
symfony/http-kernel Version ^3.4 || ^4.0 || ^5.0
symfony/options-resolver Version ^3.4 || ^4.0 || ^5.0
symfony/routing Version ^3.4 || ^4.0 || ^5.0
symfony/yaml Version ^3.4 || ^4.0 || ^5.0