Skip to content
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

Mepeiso/add false option to associations white list #538

Conversation

manuelpeiso
Copy link
Contributor

@manuelpeiso manuelpeiso commented Feb 19, 2024

#[OpenApiResponse(schemaType: 'array', associations: ['whiteList' => false])]

Will allow not load the associations. So we have a way to get the default schema without the associations loaded.

Added strict === false here: https://github.com/manuelpeiso/cakephp-swagger-bake/blob/e4c069ae05ec2fd9ef5c293fe806ad0dfd053b45/src/Lib/Operation/OperationResponseAssociation.php#L74

New test test_false_white_list created here: https://github.com/manuelpeiso/cakephp-swagger-bake/blob/e4c069ae05ec2fd9ef5c293fe806ad0dfd053b45/tests/TestCase/Lib/Operation/OperationResponseAssociationTest.php#L109

Documentation was updated to add new option.

Resolves: #537

@cnizzardini
Copy link
Owner

@manuelpeiso This looks good. Have you tested this change in your codebase?

@manuelpeiso
Copy link
Contributor Author

manuelpeiso commented Feb 19, 2024

Yes, I already used this option in this endpoint:

#[OpenApiPaginator]
#[OpenApiResponse(schemaType: 'array', associations: ['whiteList' => false])]
#[Get('houses/{house_id}/bethrooms')]
#[PatternUuid('house_id')]
public function homeBethrooms(
	BethroomSearcher $searcher
) {
    .......
}

And I can see the response I am expecting, no associations loaded:
Screenshot from 2024-02-19 13-47-07

@cnizzardini cnizzardini merged commit af01dc3 into cnizzardini:2.x Feb 19, 2024
8 checks passed
@cnizzardini cnizzardini added this to the v2.5.9 milestone Feb 19, 2024
cnizzardini added a commit that referenced this pull request Feb 25, 2024
* Mepeiso/add false option to associations white list (#538)

Allow empty whitelist of OpenApiResponse(associations: $var)
---------

Co-authored-by: Manuel Peiso <[email protected]>

* Fix extra slash being added to test src path

* Update how swagger is constructed in the test

---------

Co-authored-by: Manuel Enrique Peiso Cruz <[email protected]>
Co-authored-by: Manuel Peiso <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants