Skip to content

Allow generating documentation when property and method start from "is" #4064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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

## 2.6.2

Expand Down
13 changes: 13 additions & 0 deletions features/hal/collection.feature
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Feature: HAL Collections support
"description": "Smart dummy.",
"dummy": "SomeDummyTest1",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand All @@ -93,6 +94,7 @@ Feature: HAL Collections support
"description": "Not so smart dummy.",
"dummy": "SomeDummyTest2",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand All @@ -113,6 +115,7 @@ Feature: HAL Collections support
"description": "Smart dummy.",
"dummy": "SomeDummyTest3",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -180,6 +183,7 @@ Feature: HAL Collections support
"description": "Smart dummy.",
"dummy": "SomeDummyTest7",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand All @@ -200,6 +204,7 @@ Feature: HAL Collections support
"description": "Not so smart dummy.",
"dummy": "SomeDummyTest8",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand All @@ -220,6 +225,7 @@ Feature: HAL Collections support
"description": "Smart dummy.",
"dummy": "SomeDummyTest9",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -278,6 +284,7 @@ Feature: HAL Collections support
"description": "Not so smart dummy.",
"dummy": "SomeDummyTest10",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -339,6 +346,7 @@ Feature: HAL Collections support
"description": "Not so smart dummy.",
"dummy": "SomeDummyTest4",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand All @@ -359,6 +367,7 @@ Feature: HAL Collections support
"description": "Smart dummy.",
"dummy": "SomeDummyTest5",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand All @@ -379,6 +388,7 @@ Feature: HAL Collections support
"description": "Not so smart dummy.",
"dummy": "SomeDummyTest6",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -501,6 +511,7 @@ Feature: HAL Collections support
"description": "Not so smart dummy.",
"dummy": "SomeDummyTest2",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -550,6 +561,7 @@ Feature: HAL Collections support
"description": "Not so smart dummy.",
"dummy": "SomeDummyTest8",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -599,6 +611,7 @@ Feature: HAL Collections support
"description": "Not so smart dummy.",
"dummy": "SomeDummyTest8",
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down
2 changes: 2 additions & 0 deletions features/hal/hal.feature
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Feature: HAL support
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": "2015-03-01T10:00:00+00:00",
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -114,6 +115,7 @@ Feature: HAL support
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": "2015-03-01T10:00:00+00:00",
"dummyFloat": null,
"dummyPrice": null,
Expand Down
1 change: 1 addition & 0 deletions features/json/relation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ Feature: JSON relations support
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down
1 change: 1 addition & 0 deletions features/jsonapi/related-resouces-inclusion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ Feature: JSON API Inclusion of Related Resources
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down
9 changes: 5 additions & 4 deletions features/main/content_negotiation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Feature: Content Negotiation support
And the XML should be equal to:
"""
<?xml version="1.0"?>
<response><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>1</id><name>XML!</name><alias/><foo/></response>
<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>
"""

Scenario: Retrieve a collection in XML
Expand All @@ -31,7 +31,7 @@ Feature: Content Negotiation support
And the XML should be equal to:
"""
<?xml version="1.0"?>
<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>
<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>
"""

Scenario: Retrieve a collection in XML using the .xml URL
Expand All @@ -42,7 +42,7 @@ Feature: Content Negotiation support
And the XML should be equal to:
"""
<?xml version="1.0"?>
<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>
<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>
"""

Scenario: Retrieve a collection in JSON
Expand All @@ -58,6 +58,7 @@ Feature: Content Negotiation support
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -89,7 +90,7 @@ Feature: Content Negotiation support
And the XML should be equal to:
"""
<?xml version="1.0"?>
<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>
<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>
"""

Scenario: Requesting the same format in the Accept header and in the URL should work
Expand Down
4 changes: 4 additions & 0 deletions features/main/crud.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Feature: Create-Retrieve-Update-Delete
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": "2015-03-01T10:00:00+00:00",
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -69,6 +70,7 @@ Feature: Create-Retrieve-Update-Delete
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": "2015-03-01T10:00:00+00:00",
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -119,6 +121,7 @@ Feature: Create-Retrieve-Update-Delete
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": "2015-03-01T10:00:00+00:00",
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -523,6 +526,7 @@ Feature: Create-Retrieve-Update-Delete
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": "2018-12-01T13:12:00+00:00",
"dummyFloat": null,
"dummyPrice": null,
Expand Down
1 change: 1 addition & 0 deletions features/main/relation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Feature: Relations support
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down
2 changes: 2 additions & 0 deletions features/main/subresource.feature
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ Feature: Subresource support
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down Expand Up @@ -416,6 +417,7 @@ Feature: Subresource support
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down
5 changes: 3 additions & 2 deletions features/security/strong_typing.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Feature: Handle properly invalid data submitted to the API
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand All @@ -33,8 +34,8 @@ Feature: Handle properly invalid data submitted to the API
"jsonData": [],
"arrayData": [],
"name_converted": null,
"relatedOwnedDummy": null,
"relatedOwningDummy": null,
"relatedOwnedDummy": null,
"relatedOwningDummy": null,
"id": 1,
"name": "Not existing",
"alias": null,
Expand Down
1 change: 1 addition & 0 deletions features/security/unknown_attributes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Feature: Ignore unknown attributes
"description": null,
"dummy": null,
"dummyBoolean": null,
"isDummyBoolean": null,
"dummyDate": null,
"dummyFloat": null,
"dummyPrice": null,
Expand Down
5 changes: 4 additions & 1 deletion src/JsonSchema/SchemaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@ private function getValidationGroups(ResourceMetadata $resourceMetadata, ?string
*/
private function getFactoryOptions(array $serializerContext, array $validationGroups, ?string $operationType, ?string $operationName): array
{
$options = [];
$options = [
/* @see https://github.com/symfony/symfony/blob/v5.1.0/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php */
'enable_getter_setter_extraction' => true,
];

if (isset($serializerContext[AbstractNormalizer::GROUPS])) {
/* @see https://github.com/symfony/symfony/blob/v4.2.6/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public function testGetDescriptionDefaultFields()
'type' => 'bool',
'required' => false,
],
'isDummyBoolean' => [
'property' => 'isDummyBoolean',
'type' => 'bool',
'required' => false,
],
], $filter->getDescription($this->resourceClass));
}

Expand Down
5 changes: 5 additions & 0 deletions tests/Bridge/Doctrine/Orm/Filter/ExistsFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public function testGetDescriptionDefaultFields()
'type' => 'bool',
'required' => false,
],
'exists[isDummyBoolean]' => [
'property' => 'isDummyBoolean',
'type' => 'bool',
'required' => false,
],
], $filter->getDescription($this->resourceClass));
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Bridge/Doctrine/Orm/Filter/OrderFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@ public function testGetDescriptionDefaultFields()
],
],
],
'order[isDummyBoolean]' => [
'property' => 'isDummyBoolean',
'type' => 'string',
'required' => false,
'schema' => [
'type' => 'string',
'enum' => [
'asc',
'desc',
],
],
],
], $filter->getDescription($this->resourceClass));
}

Expand Down
25 changes: 25 additions & 0 deletions tests/Bridge/Doctrine/Orm/Filter/RangeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,31 @@ public function testGetDescriptionDefaultFields()
'type' => 'string',
'required' => false,
],
'isDummyBoolean[between]' => [
'property' => 'isDummyBoolean',
'type' => 'string',
'required' => false,
],
'isDummyBoolean[gt]' => [
'property' => 'isDummyBoolean',
'type' => 'string',
'required' => false,
],
'isDummyBoolean[gte]' => [
'property' => 'isDummyBoolean',
'type' => 'string',
'required' => false,
],
'isDummyBoolean[lt]' => [
'property' => 'isDummyBoolean',
'type' => 'string',
'required' => false,
],
'isDummyBoolean[lte]' => [
'property' => 'isDummyBoolean',
'type' => 'string',
'required' => false,
],
], $filter->getDescription($this->resourceClass));
}

Expand Down
14 changes: 14 additions & 0 deletions tests/Bridge/Doctrine/Orm/Filter/SearchFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,20 @@ public function testGetDescriptionDefaultFields()
'strategy' => 'exact',
'is_collection' => true,
],
'isDummyBoolean' => [
'property' => 'isDummyBoolean',
'type' => 'bool',
'required' => false,
'strategy' => 'exact',
'is_collection' => false,
],
'isDummyBoolean[]' => [
'property' => 'isDummyBoolean',
'type' => 'bool',
'required' => false,
'strategy' => 'exact',
'is_collection' => true,
],
], $filter->getDescription($this->resourceClass));
}

Expand Down
Loading