-
-
Notifications
You must be signed in to change notification settings - Fork 840
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
[Question]: Implementing generic classes discards the inferred type #2392
Comments
I think this might be solved by #2349 You can try using this branch and seeing if this would solve your issue 👀 // composer.json
-"nelmio/api-doc-bundle": "*",
+"nelmio/api-doc-bundle": "dev-2212-type-info", And then opt in to this new behaviour by updating your bundle config nelmio_api_doc:
experimental_type_info: true NOTE: This is still a WIP so feedback is appreciated, I would love to hear if this would fix issues like these |
@DjordyKoert Thank you for so quick response. Sadly our project is running SF6.4 now, so I couldn't test it on the project itself. I created a small sample application, where I generated the schema in initial commit and then tried to:
Sadly none of these helped, as you can see in these commits, the schema changes the same way. I wonder if this is supported with property info utilities. I do not have insights into these, but if it is, I would love to help on this feature, since it is a valid use case in my eyes :) |
This is most likely a restriction in You could (temporarily) install only |
I just found this open issue aswell for |
I see, your searching skills are better 😄 I looked quickly through the issues on property-info but didn't find it. So if the issue gets implemented in the property-info component, it could be possible to reflect it in this bundle so that the type gets correctly inferred by generator? |
Correct, but I mostly think this will be / is solved with the introduction of the TypeInfo component |
Version
4.29.0
Question
Hello. I have a question regarding a use case that I encountered on our project. We have a response structure for paginated responses. The parent class is a generic and looks like this:
The child class then implements the defined generic:
This generates the desired schema, but there is a slight inconvenience in having to specify the
@var
annotation on every child class. When it is not specified, PHPStan (running on level 8) generates no errors, since the parent already specifies the type using the generic. However, the generated schema cannot infer the type properly and instead of generatingit generates
"items": {}
My question is: Is there something wrong with our typing, or is this feature not supported by either this bundle, or the symfony property info components? Type hinting in the IDE works without specifying the
@var
tag in child components, so I suppose that PHPDocs are correct indeed.Thank you for any answers.
Additional context
No response
The text was updated successfully, but these errors were encountered: