Skip to content

Commit 2c31621

Browse files
authored
Allow generating documentation when property and method start from "is" (#4064)
1 parent f951657 commit 2c31621

20 files changed

+148
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Mercure: Do not use data in options when deleting (#4056)
66
* Doctrine: Support for foreign identifiers
7+
* SchemaFactory: Allow generating documentation when property and method start from "is" (property `isActive` and method `isActive`)
78

89
## 2.6.2
910

features/hal/collection.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Feature: HAL Collections support
7373
"description": "Smart dummy.",
7474
"dummy": "SomeDummyTest1",
7575
"dummyBoolean": null,
76+
"isDummyBoolean": null,
7677
"dummyDate": null,
7778
"dummyFloat": null,
7879
"dummyPrice": null,
@@ -93,6 +94,7 @@ Feature: HAL Collections support
9394
"description": "Not so smart dummy.",
9495
"dummy": "SomeDummyTest2",
9596
"dummyBoolean": null,
97+
"isDummyBoolean": null,
9698
"dummyDate": null,
9799
"dummyFloat": null,
98100
"dummyPrice": null,
@@ -113,6 +115,7 @@ Feature: HAL Collections support
113115
"description": "Smart dummy.",
114116
"dummy": "SomeDummyTest3",
115117
"dummyBoolean": null,
118+
"isDummyBoolean": null,
116119
"dummyDate": null,
117120
"dummyFloat": null,
118121
"dummyPrice": null,
@@ -180,6 +183,7 @@ Feature: HAL Collections support
180183
"description": "Smart dummy.",
181184
"dummy": "SomeDummyTest7",
182185
"dummyBoolean": null,
186+
"isDummyBoolean": null,
183187
"dummyDate": null,
184188
"dummyFloat": null,
185189
"dummyPrice": null,
@@ -200,6 +204,7 @@ Feature: HAL Collections support
200204
"description": "Not so smart dummy.",
201205
"dummy": "SomeDummyTest8",
202206
"dummyBoolean": null,
207+
"isDummyBoolean": null,
203208
"dummyDate": null,
204209
"dummyFloat": null,
205210
"dummyPrice": null,
@@ -220,6 +225,7 @@ Feature: HAL Collections support
220225
"description": "Smart dummy.",
221226
"dummy": "SomeDummyTest9",
222227
"dummyBoolean": null,
228+
"isDummyBoolean": null,
223229
"dummyDate": null,
224230
"dummyFloat": null,
225231
"dummyPrice": null,
@@ -278,6 +284,7 @@ Feature: HAL Collections support
278284
"description": "Not so smart dummy.",
279285
"dummy": "SomeDummyTest10",
280286
"dummyBoolean": null,
287+
"isDummyBoolean": null,
281288
"dummyDate": null,
282289
"dummyFloat": null,
283290
"dummyPrice": null,
@@ -339,6 +346,7 @@ Feature: HAL Collections support
339346
"description": "Not so smart dummy.",
340347
"dummy": "SomeDummyTest4",
341348
"dummyBoolean": null,
349+
"isDummyBoolean": null,
342350
"dummyDate": null,
343351
"dummyFloat": null,
344352
"dummyPrice": null,
@@ -359,6 +367,7 @@ Feature: HAL Collections support
359367
"description": "Smart dummy.",
360368
"dummy": "SomeDummyTest5",
361369
"dummyBoolean": null,
370+
"isDummyBoolean": null,
362371
"dummyDate": null,
363372
"dummyFloat": null,
364373
"dummyPrice": null,
@@ -379,6 +388,7 @@ Feature: HAL Collections support
379388
"description": "Not so smart dummy.",
380389
"dummy": "SomeDummyTest6",
381390
"dummyBoolean": null,
391+
"isDummyBoolean": null,
382392
"dummyDate": null,
383393
"dummyFloat": null,
384394
"dummyPrice": null,
@@ -501,6 +511,7 @@ Feature: HAL Collections support
501511
"description": "Not so smart dummy.",
502512
"dummy": "SomeDummyTest2",
503513
"dummyBoolean": null,
514+
"isDummyBoolean": null,
504515
"dummyDate": null,
505516
"dummyFloat": null,
506517
"dummyPrice": null,
@@ -550,6 +561,7 @@ Feature: HAL Collections support
550561
"description": "Not so smart dummy.",
551562
"dummy": "SomeDummyTest8",
552563
"dummyBoolean": null,
564+
"isDummyBoolean": null,
553565
"dummyDate": null,
554566
"dummyFloat": null,
555567
"dummyPrice": null,
@@ -599,6 +611,7 @@ Feature: HAL Collections support
599611
"description": "Not so smart dummy.",
600612
"dummy": "SomeDummyTest8",
601613
"dummyBoolean": null,
614+
"isDummyBoolean": null,
602615
"dummyDate": null,
603616
"dummyFloat": null,
604617
"dummyPrice": null,

features/hal/hal.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Feature: HAL support
7171
"description": null,
7272
"dummy": null,
7373
"dummyBoolean": null,
74+
"isDummyBoolean": null,
7475
"dummyDate": "2015-03-01T10:00:00+00:00",
7576
"dummyFloat": null,
7677
"dummyPrice": null,
@@ -114,6 +115,7 @@ Feature: HAL support
114115
"description": null,
115116
"dummy": null,
116117
"dummyBoolean": null,
118+
"isDummyBoolean": null,
117119
"dummyDate": "2015-03-01T10:00:00+00:00",
118120
"dummyFloat": null,
119121
"dummyPrice": null,

features/json/relation.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ Feature: JSON relations support
208208
"description": null,
209209
"dummy": null,
210210
"dummyBoolean": null,
211+
"isDummyBoolean": null,
211212
"dummyDate": null,
212213
"dummyFloat": null,
213214
"dummyPrice": null,

features/jsonapi/related-resouces-inclusion.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ Feature: JSON API Inclusion of Related Resources
338338
"description": null,
339339
"dummy": null,
340340
"dummyBoolean": null,
341+
"isDummyBoolean": null,
341342
"dummyDate": null,
342343
"dummyFloat": null,
343344
"dummyPrice": null,

features/main/content_negotiation.feature

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Feature: Content Negotiation support
1919
And the XML should be equal to:
2020
"""
2121
<?xml version="1.0"?>
22-
<response><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>1</id><name>XML!</name><alias/><foo/></response>
22+
<response><description/><dummy/><dummyBoolean/><isDummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>1</id><name>XML!</name><alias/><foo/></response>
2323
"""
2424

2525
Scenario: Retrieve a collection in XML
@@ -31,7 +31,7 @@ Feature: Content Negotiation support
3131
And the XML should be equal to:
3232
"""
3333
<?xml version="1.0"?>
34-
<response><item key="0"><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>1</id><name>XML!</name><alias/><foo/></item></response>
34+
<response><item key="0"><description/><dummy/><dummyBoolean/><isDummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>1</id><name>XML!</name><alias/><foo/></item></response>
3535
"""
3636

3737
Scenario: Retrieve a collection in XML using the .xml URL
@@ -42,7 +42,7 @@ Feature: Content Negotiation support
4242
And the XML should be equal to:
4343
"""
4444
<?xml version="1.0"?>
45-
<response><item key="0"><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>1</id><name>XML!</name><alias/><foo/></item></response>
45+
<response><item key="0"><description/><dummy/><dummyBoolean/><isDummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>1</id><name>XML!</name><alias/><foo/></item></response>
4646
"""
4747

4848
Scenario: Retrieve a collection in JSON
@@ -58,6 +58,7 @@ Feature: Content Negotiation support
5858
"description": null,
5959
"dummy": null,
6060
"dummyBoolean": null,
61+
"isDummyBoolean": null,
6162
"dummyDate": null,
6263
"dummyFloat": null,
6364
"dummyPrice": null,
@@ -89,7 +90,7 @@ Feature: Content Negotiation support
8990
And the XML should be equal to:
9091
"""
9192
<?xml version="1.0"?>
92-
<response><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>2</id><name>Sent in JSON</name><alias/><foo/></response>
93+
<response><description/><dummy/><dummyBoolean/><isDummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>2</id><name>Sent in JSON</name><alias/><foo/></response>
9394
"""
9495

9596
Scenario: Requesting the same format in the Accept header and in the URL should work

features/main/crud.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Feature: Create-Retrieve-Update-Delete
3333
"description": null,
3434
"dummy": null,
3535
"dummyBoolean": null,
36+
"isDummyBoolean": null,
3637
"dummyDate": "2015-03-01T10:00:00+00:00",
3738
"dummyFloat": null,
3839
"dummyPrice": null,
@@ -69,6 +70,7 @@ Feature: Create-Retrieve-Update-Delete
6970
"description": null,
7071
"dummy": null,
7172
"dummyBoolean": null,
73+
"isDummyBoolean": null,
7274
"dummyDate": "2015-03-01T10:00:00+00:00",
7375
"dummyFloat": null,
7476
"dummyPrice": null,
@@ -119,6 +121,7 @@ Feature: Create-Retrieve-Update-Delete
119121
"description": null,
120122
"dummy": null,
121123
"dummyBoolean": null,
124+
"isDummyBoolean": null,
122125
"dummyDate": "2015-03-01T10:00:00+00:00",
123126
"dummyFloat": null,
124127
"dummyPrice": null,
@@ -523,6 +526,7 @@ Feature: Create-Retrieve-Update-Delete
523526
"description": null,
524527
"dummy": null,
525528
"dummyBoolean": null,
529+
"isDummyBoolean": null,
526530
"dummyDate": "2018-12-01T13:12:00+00:00",
527531
"dummyFloat": null,
528532
"dummyPrice": null,

features/main/relation.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ Feature: Relations support
155155
"description": null,
156156
"dummy": null,
157157
"dummyBoolean": null,
158+
"isDummyBoolean": null,
158159
"dummyDate": null,
159160
"dummyFloat": null,
160161
"dummyPrice": null,

features/main/subresource.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ Feature: Subresource support
383383
"description": null,
384384
"dummy": null,
385385
"dummyBoolean": null,
386+
"isDummyBoolean": null,
386387
"dummyDate": null,
387388
"dummyFloat": null,
388389
"dummyPrice": null,
@@ -416,6 +417,7 @@ Feature: Subresource support
416417
"description": null,
417418
"dummy": null,
418419
"dummyBoolean": null,
420+
"isDummyBoolean": null,
419421
"dummyDate": null,
420422
"dummyFloat": null,
421423
"dummyPrice": null,

features/security/strong_typing.feature

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Feature: Handle properly invalid data submitted to the API
2525
"description": null,
2626
"dummy": null,
2727
"dummyBoolean": null,
28+
"isDummyBoolean": null,
2829
"dummyDate": null,
2930
"dummyFloat": null,
3031
"dummyPrice": null,
@@ -33,8 +34,8 @@ Feature: Handle properly invalid data submitted to the API
3334
"jsonData": [],
3435
"arrayData": [],
3536
"name_converted": null,
36-
"relatedOwnedDummy": null,
37-
"relatedOwningDummy": null,
37+
"relatedOwnedDummy": null,
38+
"relatedOwningDummy": null,
3839
"id": 1,
3940
"name": "Not existing",
4041
"alias": null,

features/security/unknown_attributes.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Feature: Ignore unknown attributes
2525
"description": null,
2626
"dummy": null,
2727
"dummyBoolean": null,
28+
"isDummyBoolean": null,
2829
"dummyDate": null,
2930
"dummyFloat": null,
3031
"dummyPrice": null,

src/JsonSchema/SchemaFactory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ private function getValidationGroups(ResourceMetadata $resourceMetadata, ?string
325325
*/
326326
private function getFactoryOptions(array $serializerContext, array $validationGroups, ?string $operationType, ?string $operationName): array
327327
{
328-
$options = [];
328+
$options = [
329+
/* @see https://github.com/symfony/symfony/blob/v5.1.0/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php */
330+
'enable_getter_setter_extraction' => true,
331+
];
329332

330333
if (isset($serializerContext[AbstractNormalizer::GROUPS])) {
331334
/* @see https://github.com/symfony/symfony/blob/v4.2.6/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php */

tests/Bridge/Doctrine/Common/Filter/BooleanFilterTestTrait.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public function testGetDescriptionDefaultFields()
4646
'type' => 'bool',
4747
'required' => false,
4848
],
49+
'isDummyBoolean' => [
50+
'property' => 'isDummyBoolean',
51+
'type' => 'bool',
52+
'required' => false,
53+
],
4954
], $filter->getDescription($this->resourceClass));
5055
}
5156

tests/Bridge/Doctrine/Orm/Filter/ExistsFilterTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public function testGetDescriptionDefaultFields()
9090
'type' => 'bool',
9191
'required' => false,
9292
],
93+
'exists[isDummyBoolean]' => [
94+
'property' => 'isDummyBoolean',
95+
'type' => 'bool',
96+
'required' => false,
97+
],
9398
], $filter->getDescription($this->resourceClass));
9499
}
95100

tests/Bridge/Doctrine/Orm/Filter/OrderFilterTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ public function testGetDescriptionDefaultFields()
180180
],
181181
],
182182
],
183+
'order[isDummyBoolean]' => [
184+
'property' => 'isDummyBoolean',
185+
'type' => 'string',
186+
'required' => false,
187+
'schema' => [
188+
'type' => 'string',
189+
'enum' => [
190+
'asc',
191+
'desc',
192+
],
193+
],
194+
],
183195
], $filter->getDescription($this->resourceClass));
184196
}
185197

tests/Bridge/Doctrine/Orm/Filter/RangeFilterTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,31 @@ public function testGetDescriptionDefaultFields()
332332
'type' => 'string',
333333
'required' => false,
334334
],
335+
'isDummyBoolean[between]' => [
336+
'property' => 'isDummyBoolean',
337+
'type' => 'string',
338+
'required' => false,
339+
],
340+
'isDummyBoolean[gt]' => [
341+
'property' => 'isDummyBoolean',
342+
'type' => 'string',
343+
'required' => false,
344+
],
345+
'isDummyBoolean[gte]' => [
346+
'property' => 'isDummyBoolean',
347+
'type' => 'string',
348+
'required' => false,
349+
],
350+
'isDummyBoolean[lt]' => [
351+
'property' => 'isDummyBoolean',
352+
'type' => 'string',
353+
'required' => false,
354+
],
355+
'isDummyBoolean[lte]' => [
356+
'property' => 'isDummyBoolean',
357+
'type' => 'string',
358+
'required' => false,
359+
],
335360
], $filter->getDescription($this->resourceClass));
336361
}
337362

tests/Bridge/Doctrine/Orm/Filter/SearchFilterTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ public function testGetDescriptionDefaultFields()
214214
'strategy' => 'exact',
215215
'is_collection' => true,
216216
],
217+
'isDummyBoolean' => [
218+
'property' => 'isDummyBoolean',
219+
'type' => 'bool',
220+
'required' => false,
221+
'strategy' => 'exact',
222+
'is_collection' => false,
223+
],
224+
'isDummyBoolean[]' => [
225+
'property' => 'isDummyBoolean',
226+
'type' => 'bool',
227+
'required' => false,
228+
'strategy' => 'exact',
229+
'is_collection' => true,
230+
],
217231
], $filter->getDescription($this->resourceClass));
218232
}
219233

0 commit comments

Comments
 (0)