cnizzardini / cakephp-swagger-bake

Automatically generate OpenAPI, Swagger, and Redoc documentation from your existing CakePHP code.
http://cakephpswaggerbake.cnizz.com/
MIT License
59 stars 20 forks source link

Mepeiso/add false option to associations white list #538

Closed manuelpeiso closed 7 months ago

manuelpeiso commented 7 months ago

#[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 commented 7 months ago

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

manuelpeiso commented 7 months ago

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