Skip to content

Commit 423bf87

Browse files
committed
Merge branch 'master' into 5.x
# Conflicts: # .github/workflows/continuous-integration.yml # .php-cs-fixer.dist.php # CHANGELOG.md # composer.json # docs/alternative_names.rst # docs/areas.rst # docs/faq.rst # docs/index.rst # docs/security.rst # phpstan-baseline.neon # phpunit-ignore.txt # src/ApiDocGenerator.php # src/Attribute/Areas.php # src/Attribute/Model.php # src/Attribute/Operation.php # src/Attribute/Security.php # src/Describer/OpenApiPhpDescriber.php # src/Model/Model.php # src/ModelDescriber/Annotations/AnnotationsReader.php # src/ModelDescriber/Annotations/ReflectionReader.php # src/ModelDescriber/EnumModelDescriber.php # src/ModelDescriber/FormModelDescriber.php # src/ModelDescriber/JMSModelDescriber.php # src/ModelDescriber/ObjectModelDescriber.php # src/PropertyDescriber/ObjectPropertyDescriber.php # src/PropertyDescriber/PropertyDescriber.php # src/PropertyDescriber/PropertyDescriberInterface.php # src/PropertyDescriber/RequiredPropertyDescriber.php # src/Routing/FilteredRouteCollectionBuilder.php # tests/Functional/Controller/ApiController81.php # tests/Functional/Controller/JMSController81.php # tests/Functional/Controller/MapQueryParameterController.php # tests/Functional/Controller/MapQueryStringController.php # tests/Functional/Entity/EntityWithPromotedPropertiesWithDefaults80.php # tests/Functional/JMSFunctionalTest.php
2 parents af67c9b + 86d1a11 commit 423bf87

File tree

93 files changed

+2617
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2617
-194
lines changed

.doctor-rst.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ rules:
5353

5454
# master
5555
versionadded_directive_major_version:
56-
major_version: 6
56+
major_version: 7
5757

5858
versionadded_directive_min_version:
59-
min_version: '6.0'
59+
min_version: '7.0'
6060

6161
deprecated_directive_major_version:
62-
major_version: 5
62+
major_version: 6
6363

6464
deprecated_directive_min_version:
65-
min_version: '5.0'
65+
min_version: '6.0'
6666

6767
# do not report as violation
6868
whitelist:

.github/workflows/continuous-integration.yml

+19-7
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,32 @@ jobs:
3030
composer-flags: "--prefer-lowest"
3131
- php-version: 8.1
3232
symfony-require: "5.4"
33+
- php-version: 8.2
34+
symfony-require: "5.4"
3335
- php-version: 8.3
3436
symfony-require: "5.4"
37+
- php-version: 8.4
38+
symfony-require: "5.4"
3539
- php-version: 8.1
3640
symfony-require: "6.4"
37-
- php-version: 8.3
38-
symfony-require: "6.4"
3941
- php-version: 8.2
40-
symfony-require: "7.0"
42+
symfony-require: "6.4"
4143
- php-version: 8.3
42-
symfony-require: "7.0"
44+
symfony-require: "6.4"
45+
- php-version: 8.4
46+
symfony-require: "6.4"
4347
- php-version: 8.2
4448
symfony-require: "7.1"
4549
- php-version: 8.3
4650
symfony-require: "7.1"
51+
- php-version: 8.4
52+
symfony-require: "7.1"
53+
- php-version: 8.2
54+
symfony-require: "7.2"
55+
- php-version: 8.3
56+
symfony-require: "7.2"
57+
- php-version: 8.4
58+
symfony-require: "7.2"
4759
steps:
4860
- name: Checkout
4961
uses: actions/checkout@v4
@@ -104,7 +116,7 @@ jobs:
104116
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
105117

106118
- name: Upload code coverage to Codecov.io
107-
uses: codecov/codecov-action@v4
119+
uses: codecov/codecov-action@v5
108120
with:
109121
fail_ci_if_error: true
110122
env:
@@ -130,7 +142,7 @@ jobs:
130142
- name: Setup dependencies
131143
uses: ./.github/workflows/common/composer-install
132144
with:
133-
symfony-version: "7.0.*"
145+
symfony-version: "7.2.*"
134146

135147
- name: Run PHP-CS-Fixer
136148
run: vendor/bin/php-cs-fixer check -v --diff
@@ -155,7 +167,7 @@ jobs:
155167
- name: Setup dependencies
156168
uses: ./.github/workflows/common/composer-install
157169
with:
158-
symfony-version: "7.0.*"
170+
symfony-version: "7.2.*"
159171

160172
- name: Run PHPStan
161173
run: vendor/bin/phpstan analyse --memory-limit=2G --no-progress --no-interaction

.php-cs-fixer.dist.php

+16-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the NelmioApiDocBundle package.
7+
*
8+
* (c) Nelmio
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
$finder = (new PhpCsFixer\Finder())
615
->in(__DIR__)
716
->exclude('var')
8-
->exclude('tests/Functional/cache');
17+
->exclude('tests/Functional/cache')
18+
->exclude('tests/Functional/ModelDescriber/Fixtures');
919

1020
return (new PhpCsFixer\Config())
1121
->setRiskyAllowed(true)
@@ -15,13 +25,13 @@
1525
'@PHP84Migration' => true,
1626
'header_comment' => [
1727
'header' => <<<HEADER
18-
This file is part of the NelmioApiDocBundle package.
28+
This file is part of the NelmioApiDocBundle package.
1929
20-
(c) Nelmio
30+
(c) Nelmio
2131
22-
For the full copyright and license information, please view the LICENSE
23-
file that was distributed with this source code.
24-
HEADER
32+
For the full copyright and license information, please view the LICENSE
33+
file that was distributed with this source code.
34+
HEADER
2535
],
2636
])
2737
->setFinder($finder);

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# CHANGELOG
22

3+
## 4.35.0
4+
* Added support for the symfony/type-info component
5+
```yaml
6+
nelmio_api_doc:
7+
type_info: true
8+
```
9+
10+
## 4.34.0
11+
* Changed minimum Symfony version for 7.x from 7.0 to 7.1
12+
13+
## 4.33.6
14+
* Fixed Symfony 7.2 deprecation of tagged arguments
15+
16+
## 4.33.5
17+
* Added new optional parameter `$context` to` PropertyDescriberInterface::supports()`
18+
319
## 4.33.4
420
* Deprecated `null` type from `$options` in `Nelmio\ApiDocBundle\Attribute\Model::__construct()`. Pass an empty array (`[]`) instead.
521
* Deprecated `null` type from `$options` in `NNelmio\ApiDocBundle\Attribute\Model::__construct()`. Pass an empty array (`[]`) instead.

composer.json

+24-24
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
"psr/cache": "^1.0 || ^2.0 || ^3.0",
1919
"psr/container": "^1.0 || ^2.0",
2020
"psr/log": "^1.0 || ^2.0 || ^3.0",
21-
"symfony/config": "^5.4 || ^6.4 || ^7.0",
22-
"symfony/console": "^5.4 || ^6.4 || ^7.0",
23-
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0",
21+
"symfony/config": "^5.4 || ^6.4 || ^7.1",
22+
"symfony/console": "^5.4 || ^6.4 || ^7.1",
23+
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.1",
2424
"symfony/deprecation-contracts": "^2.1 || ^3",
25-
"symfony/framework-bundle": "^5.4.24 || ^6.4 || ^7.0",
26-
"symfony/http-foundation": "^5.4 || ^6.4 || ^7.0",
27-
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.0",
28-
"symfony/options-resolver": "^5.4 || ^6.4 || ^7.0",
29-
"symfony/property-info": "^5.4.10 || ^6.4 || ^7.0",
30-
"symfony/routing": "^5.4 || ^6.4 || ^7.0",
31-
"zircote/swagger-php": "^4.6.1"
25+
"symfony/framework-bundle": "^5.4.24 || ^6.4 || ^7.1",
26+
"symfony/http-foundation": "^5.4 || ^6.4 || ^7.1",
27+
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.1",
28+
"symfony/options-resolver": "^5.4 || ^6.4 || ^7.1",
29+
"symfony/property-info": "^5.4.10 || ^6.4 || ^7.1",
30+
"symfony/routing": "^5.4 || ^6.4 || ^7.1",
31+
"zircote/swagger-php": "^4.11.1 || ^5.0"
3232
},
3333
"require-dev": {
3434
"api-platform/core": "^2.7.0 || ^3",
@@ -41,21 +41,21 @@
4141
"phpstan/phpstan-strict-rules": "^1.5",
4242
"phpstan/phpstan-symfony": "^1.3",
4343
"phpunit/phpunit": "^10.5",
44-
"symfony/asset": "^5.4 || ^6.4 || ^7.0",
45-
"symfony/browser-kit": "^5.4 || ^6.4 || ^7.0",
46-
"symfony/cache": "^5.4 || ^6.4 || ^7.0",
47-
"symfony/dom-crawler": "^5.4 || ^6.4 || ^7.0",
48-
"symfony/expression-language": "^5.4 || ^6.4 || ^7.0",
49-
"symfony/form": "^5.4 || ^6.4 || ^7.0",
44+
"symfony/asset": "^5.4 || ^6.4 || ^7.1",
45+
"symfony/browser-kit": "^5.4 || ^6.4 || ^7.1",
46+
"symfony/cache": "^5.4 || ^6.4 || ^7.1",
47+
"symfony/dom-crawler": "^5.4 || ^6.4 || ^7.1",
48+
"symfony/expression-language": "^5.4 || ^6.4 || ^7.1",
49+
"symfony/form": "^5.4 || ^6.4 || ^7.1",
5050
"symfony/phpunit-bridge": "^6.4",
51-
"symfony/property-access": "^5.4 || ^6.4 || ^7.0",
52-
"symfony/security-csrf": "^5.4 || ^6.4 || ^7.0",
53-
"symfony/serializer": "^5.4 || ^6.4 || ^7.0",
54-
"symfony/stopwatch": "^5.4 || ^6.4 || ^7.0",
55-
"symfony/templating": "^5.4 || ^6.4 || ^7.0",
56-
"symfony/twig-bundle": "^5.4 || ^6.4 || ^7.0",
57-
"symfony/uid": "^5.4 || ^6.4 || ^7.0",
58-
"symfony/validator": "^5.4 || ^6.4 || ^7.0",
51+
"symfony/property-access": "^5.4 || ^6.4 || ^7.1",
52+
"symfony/security-csrf": "^5.4 || ^6.4 || ^7.1",
53+
"symfony/serializer": "^5.4 || ^6.4 || ^7.1",
54+
"symfony/stopwatch": "^5.4 || ^6.4 || ^7.1",
55+
"symfony/templating": "^5.4 || ^6.4 || ^7.1",
56+
"symfony/twig-bundle": "^5.4 || ^6.4 || ^7.1",
57+
"symfony/uid": "^5.4 || ^6.4 || ^7.1",
58+
"symfony/validator": "^5.4 || ^6.4 || ^7.1",
5959
"willdurand/hateoas-bundle": "^2.7@beta",
6060
"willdurand/negotiation": "^3.0"
6161
},

config/services.xml

+60-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101

102102
<!-- Property Describers -->
103103
<service id="nelmio_api_doc.object_model.property_describer" class="Nelmio\ApiDocBundle\PropertyDescriber\PropertyDescriber" public="false">
104-
<argument type="tagged" tag="nelmio_api_doc.object_model.property_describer" />
104+
<argument type="tagged_iterator" tag="nelmio_api_doc.object_model.property_describer" />
105105

106106
<tag name="nelmio_api_doc.object_model.property_describer" priority="100" />
107107
</service>
@@ -160,6 +160,65 @@
160160
<service id="nelmio_api_doc.swagger.processor.nullable_property" class="Nelmio\ApiDocBundle\Processor\NullablePropertyProcessor">
161161
<tag name="nelmio_api_doc.swagger.processor" />
162162
</service>
163+
164+
<!-- Type describers (symfony/type-info) -->
165+
<service id="nelmio_api_doc.type_describer.chain" class="Nelmio\ApiDocBundle\TypeDescriber\ChainDescriber" public="false">
166+
<argument type="tagged" tag="nelmio_api_doc.type_describer" />
167+
168+
<tag name="nelmio_api_doc.type_describer" priority="1000" />
169+
</service>
170+
171+
<service id="nelmio_api_doc.type_describer.array" class="Nelmio\ApiDocBundle\TypeDescriber\ArrayDescriber" public="false">
172+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
173+
</service>
174+
175+
<service id="nelmio_api_doc.type_describer.bool" class="Nelmio\ApiDocBundle\TypeDescriber\BoolDescriber" public="false">
176+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
177+
</service>
178+
179+
<service id="nelmio_api_doc.type_describer.class" class="Nelmio\ApiDocBundle\TypeDescriber\ClassDescriber" public="false">
180+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
181+
</service>
182+
183+
<service id="nelmio_api_doc.type_describer.dictionary" class="Nelmio\ApiDocBundle\TypeDescriber\DictionaryDescriber" public="false">
184+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
185+
</service>
186+
187+
<service id="nelmio_api_doc.type_describer.float" class="Nelmio\ApiDocBundle\TypeDescriber\FloatDescriber" public="false">
188+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
189+
</service>
190+
191+
<service id="nelmio_api_doc.type_describer.integer" class="Nelmio\ApiDocBundle\TypeDescriber\IntegerDescriber" public="false">
192+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
193+
</service>
194+
195+
<service id="nelmio_api_doc.type_describer.intersection" class="Nelmio\ApiDocBundle\TypeDescriber\IntersectionDescriber" public="false">
196+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
197+
</service>
198+
199+
<service id="nelmio_api_doc.type_describer.list" class="Nelmio\ApiDocBundle\TypeDescriber\ListDescriber" public="false">
200+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
201+
</service>
202+
203+
<service id="nelmio_api_doc.type_describer.mixed" class="Nelmio\ApiDocBundle\TypeDescriber\MixedDescriber" public="false">
204+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
205+
</service>
206+
207+
<service id="nelmio_api_doc.type_describer.nullable" class="Nelmio\ApiDocBundle\TypeDescriber\NullableDescriber" public="false">
208+
<tag name="nelmio_api_doc.type_describer" priority="-950" />
209+
</service>
210+
211+
<service id="nelmio_api_doc.type_describer.object" class="Nelmio\ApiDocBundle\TypeDescriber\ObjectDescriber" public="false">
212+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
213+
</service>
214+
215+
<service id="nelmio_api_doc.type_describer.string" class="Nelmio\ApiDocBundle\TypeDescriber\StringDescriber" public="false">
216+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
217+
</service>
218+
219+
<service id="nelmio_api_doc.type_describer.union" class="Nelmio\ApiDocBundle\TypeDescriber\UnionDescriber" public="false">
220+
<tag name="nelmio_api_doc.type_describer" priority="-1000" />
221+
</service>
163222
</services>
164223

165224
</container>

docs/areas.rst

-1
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,3 @@ Then add the attribute before your controller or action::
102102
...
103103
}
104104
}
105-

docs/faq.rst

+52-3
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ A: Use ``#[OA\Tag]`` attribute.
195195
// ...
196196
}
197197
198-
199198
Disable Default Section
200199
-----------------------
201200

@@ -216,7 +215,7 @@ Overriding a Form or Plain PHP Object Schema Type
216215
Q: I'd like to define a PHP object or form with a type other any ``object``, how
217216
do I do that?
218217

219-
A: By using the ``#[OA\Schema]`` attribute with a ``type`` or ``ref``.
218+
A: By using the ``#[OA\Schema]`` attribute/annotation with a ``type`` or ``ref``.
220219
Note, however, that a ``type="object"`` will still read all a models properties.
221220

222221
.. configuration-block::
@@ -234,4 +233,54 @@ Note, however, that a ``type="object"`` will still read all a models properties.
234233
class SomeCollection implements \IteratorAggregate
235234
{
236235
// ...
237-
}
236+
}
237+
238+
PropertyInfo component was unable to guess the type
239+
---------------------------------------------------
240+
241+
Q: I have a property that is not recognized. How can I specify the type?
242+
243+
.. tip::
244+
245+
Enable the `TypeInfo component`_ in your configuration to improve automatic type guessing:
246+
247+
.. code-block:: yaml
248+
249+
nelmio_api_doc:
250+
type_info: true
251+
# ...
252+
253+
.. versionadded:: 7.2
254+
255+
The `TypeInfo component`_ was introduced as a stable feature in Symfony 7.2.
256+
257+
A: If you want to customize the documentation of an object's property, you can use the ``#[OA\Property]`` attribute or annotate the property with ``@var``::
258+
259+
.. configuration-block::
260+
261+
.. code-block:: php-attributes
262+
263+
use Nelmio\ApiDocBundle\Attribute\Model;
264+
use OpenApi\Attributes as OA;
265+
266+
class User
267+
{
268+
/**
269+
* @var int
270+
*/
271+
#[OA\Property(description: 'The unique identifier of the user.')]
272+
public $id;
273+
274+
#[OA\Property(type: 'string', maxLength: 255)]
275+
public $username;
276+
277+
#[OA\Property(ref: new Model(type: User::class))]
278+
public $friend;
279+
280+
#[OA\Property(description: 'This is my coworker!')]
281+
public setCoworker(User $coworker) {
282+
// ...
283+
}
284+
}
285+
286+
.. _`TypeInfo component`: https://symfony.com/doc/current/components/type_info.html

0 commit comments

Comments
 (0)