-
-
Notifications
You must be signed in to change notification settings - Fork 868
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
If docs are disabled, do not try to add a link header to the docs #1731
If docs are disabled, do not try to add a link header to the docs #1731
Conversation
e9c22a2
to
a15f7fa
Compare
Hydra cannot work if the docs aren't available. It doesn't make sense to disable the docs without disabling Hydra. |
Not if you have your own docs (like something built with slate, postmann, confluence, ...). It's just that the swagger docs are disabled. |
Maybe what could be done would be to add a parameter or something that points to the doc, which defaults to the generation of the |
Well the documentation is a feature of hydra. If you decide to remove that feature it should be supported everywhere in api-platform. Or it should throw an exception because of incoherent configuration. |
IMO we must never disable the Hydra docs (or throw) when JSON-LD is enabled. The hydra "doc" is mandatory for JSON-LD (because we use Hydra types everywhere in JSON-LD documents) and Hydra compliance. |
@@ -22,6 +22,7 @@ | |||
|
|||
<service id="api_platform.hydra.listener.response.add_link_header" class="ApiPlatform\Core\Hydra\EventListener\AddLinkHeaderListener"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be cleaner to remove the service if this flag is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, but wouldn't this be in opposition to the fact that hydra needs this header ? It's the same thing as what I proposed, but still...
a15f7fa
to
42d2efd
Compare
@dunglas But is it obligatory to use swagger for that ? Can't we use something else, and thus not depend on an |
@dunglas if you disable the documentation it looks pretty normal to disable it from everywhere. A notice may be added to the documentation. For example, I have a fully private application and I don't want to expose any documentation of the service. Of course, if the documentation would be managed with rights you may make a point to us (we actually have developed a similar system so the front can discover some services). But as it's dangerous, adding the possibility to fully delete any feature related to the doc is relevant. |
After a second look, it looks ok to have partial Hydra support, so 👍 on my side, but can you please add a test? |
42d2efd
to
862db7e
Compare
test added @dunglas (and I fixed the |
Thanks @Taluu |
Found this bug today too. I have Symfony web page and I do not want to expose any info about api platform outside the world via header Link so I disabled docs and bug appeared. Waiting for new Api Platform Release @dunglas + have a look at my pull in Symfony PropertyInfo\DoctrineExtractor |
Even if the docs are disabled, the
AddLinkHeader
listener tries to add aLink
header to theapi_doc
route. But the generator fails if the route does not exists, triggers a 500 instead of having an expected result.Checking for the parameter
%api_platform.enable_docs%
solves the problem.