mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Christopher Davis
883d7b6c89
Apply
enum
from Choice Constraints to Items When Choice is Multiple (#1784)
* Apply `enum` from Choice Constraints to Items When Choice is Multiple Otherwise JSON schema like this is generated: ``` "property": { "type": "array", "enum": ["one", "two", "three"], "items": { "type": "string" } } ``` With this change, however, this schema is generated: ``` "property": { "type": "array", "items": { "type": "string", "enum": ["one", "two", "three"] } } ``` A possible downside here is that the symfony constraint stuff happens before types are figured out from PHPDoc. So it's _possible_ to end up with something that won't validated. Take something like this: ``` /** * @Assert\Choice(multiple=true, choices={"..."}) * @var string */ ``` This would generate: ``` "property": { "type": "string", "items": { "enum": ["..."] } } ``` * Fix CS * cs * more cs * fix tests Co-authored-by: Guilhem Niot <guilhem@gniot.fr>
NelmioApiDocBundle
The NelmioApiDocBundle bundle allows you to generate a decent documentation for your APIs.
Migrate from 3.x to 4.0
To migrate from 3.x to 4.0, follow our guide.
Version 4.0 brings OpenAPI 3.0 support. If you want to stick to Swagger 2.0, you should use the version 3 of this bundle.
Migrate from 2.x to 3.0
To migrate from 2.x to 3.0, follow our guide.
Installation
Open a command console, enter your project directory and execute the following command to download the latest version of this bundle:
composer require nelmio/api-doc-bundle
Documentation
Read the documentation on symfony.com
Contributing
See CONTRIBUTING file.
Running the Tests
Install the Composer dependencies:
git clone https://github.com/nelmio/NelmioApiDocBundle.git
cd NelmioApiDocBundle
composer update
Then run the test suite:
./phpunit
License
This bundle is released under the MIT license.
Description
Languages
PHP
86.4%
Twig
11%
CSS
2.5%