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

Hard to find out problem with invalid attribute #1267

Closed
zim32 opened this issue Jun 22, 2022 · 6 comments
Closed

Hard to find out problem with invalid attribute #1267

zim32 opened this issue Jun 22, 2022 · 6 comments

Comments

@zim32
Copy link
Contributor

zim32 commented Jun 22, 2022

Right now, invalid attribute is logged with DEBUG level.
Default logger just ignores this level.

So it is impossible to know if something whent wrong f.e.when instantiating OA\Get(...) attribute throws excpeption, it is silently dropped.
Don't know how to improve, just point this issue.

@DerManoMann
Copy link
Collaborator

I guess this depends on whether you are using a 3rd party tool or swagger-php directly.

You can always pass a custom Psr\Logger instance into the Generator or run ./bin/openapi with --debug

@DerManoMann
Copy link
Collaborator

I suppose https://github.com/zircote/swagger-php/blob/master/src/Analysers/AttributeAnnotationFactory.php#L52 could be conditional depending on whether the attribute class was OpenApi related or not.

Not being able to instantiate unrelated attributes (for example JetBrains\PhpStorm\Pure or similar) should not be considered important in the context of swagger-php.

@zim32
Copy link
Contributor Author

zim32 commented Sep 12, 2022

I guess this depends on whether you are using a 3rd party tool or swagger-php directly.

You can always pass a custom Psr\Logger instance into the Generator or run ./bin/openapi with --debug

Maybe it should be more explicitly mentioned in the docs. Because I need to spend quite a lot of time to figure out the problem

@DerManoMann
Copy link
Collaborator

Maybe. Where would you expect that to documented then?
There is always the option to create a pull request to improve the docs ;) they still need quite some love...

@zim32
Copy link
Contributor Author

zim32 commented Sep 12, 2022

Docs are awesome. I have only this issue with ignoring exception. Thanks for this project, I am using it on many own projects. I will create pr if I have time ) as usual time is most valuable thing

stollr added a commit to stollr/zircote-swagger-php that referenced this issue Mar 21, 2023
The error catching made it hard to find the reason for "ignored" attributes. This change addresses the issues zircote#1267 and zircote#1162.

Instead of catching errors of non existing attribute classes, the existence of the class is checked before the attribute is tried to instantiate. This reveals invalid attribute definitions, but there won't be shown errors for attributes whose class definitions do not exist.
@stollr
Copy link
Contributor

stollr commented Mar 21, 2023

I had the same issue and it took me several hours to find the reason why a property wasn't added to the spec. I hope my PR gets merged to prevent this kind of issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants