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

Add Symfony attribute describers #2112

Merged
merged 125 commits into from
Jan 15, 2024

Conversation

DjordyKoert
Copy link
Collaborator

Symfony 6.3 added the possibility for developers to map request data to typed objects. This release also included the addition of mapping query parameters.

This made me wonder why NelmioApiDocBundle wouldn't be able to automatically create basic documentation when these attributes are present.

@SBNTT
Copy link

SBNTT commented Jan 5, 2024

allOf representation is back and fixed the issue. Is it temporary until swapper-php issue is solved ?

You also fixed another issue (weird duplicated Models). That's cool !

There is only one remaining issue:
The schema object is not supposed to have a property property as indicated in https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#schemaObject. This value is already set by the parameter object's name property (https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterObject)

@DjordyKoert
Copy link
Collaborator Author

allOf representation is back and fixed the issue. Is it temporary until swapper-php issue is solved ?

Yup this is hopefully temporary, this was the fix for now. zircote/swagger-php#1528

There is only one remaining issue: The schema object is not supposed to have a property property as indicated in https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#schemaObject. This value is already set by the parameter object's name property (OAI/OpenAPI-Specification@main/versions/3.0.3.md#parameterObject)

Yup thats one of the things still on my 'todo' list. The other one is finding a way to prevent breaking the docs generation whenever #[OA\RequestBody(content: new Model(...)] is used in combination with MapRequestPayload.

@DjordyKoert
Copy link
Collaborator Author

@SBNTT Managed to fix everything + tests for all situations 😄

@SBNTT
Copy link

SBNTT commented Jan 5, 2024

Yaay !
I've just tested it, and it's working perfectly now.

For months, we had a script that was postprocessing the generated OA specs using some ugly regexps, but you've fixed everything :)

Thanks for your hard work @DjordyKoert !

@BafS
Copy link
Contributor

BafS commented Jan 5, 2024

Thanks a lot @DjordyKoert for this amazing PR, I hope to see it merged soon

# Conflicts:
#	Tests/Functional/Controller/ApiController81.php
#	phpunit-baseline.json
@DjordyKoert DjordyKoert merged commit 9b642df into nelmio:master Jan 15, 2024
13 checks passed
@DjordyKoert DjordyKoert deleted the symfony-map-request-data branch January 15, 2024 14:14
@akankov
Copy link

akankov commented Jan 15, 2024

Hi, I'm glad it was finally merged.
But I have some problems with that
It looks like MapRequestPayloadProcessor does not support validationGroups and, because of that, there is no difference between

#[MapRequestPayload(validationGroups: [EntityDTO::GROUP_CREATE])] EntityDTO $data

and

#[MapRequestPayload(validationGroups: [EntityDTO::GROUP_UPDATE])] EntityDTO $data

Every time, it picks up the complete set of fields and ignores groups.

@DjordyKoert
Copy link
Collaborator Author

@akankov thank you, fixed it in #2189

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.

9 participants