-
-
Notifications
You must be signed in to change notification settings - Fork 888
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 a new attribute for "placeholder" routes #3051
Comments
I think it's better to provide a URN or a Skolem IRI (see below) in such cases. We avoid the whole mess altogether. |
|
"Cool IRIs don't change". If at some point you want to expose this resource through the web, (and it often happen in the world of web APIs), using an URI from the very beginning (even if it isn't dereferenceable yet) is better. |
Completely disagree here. I'm not sure that returning HTTP 404 even qualifies as a "dereferenceable" IRI.
That's only applicable when we're talking about web IRIs. It's irrelevant when we're using a URN or a Skolem IRI.
It should not even hit the router at all. 😉 |
My point is that we're actually talking about that! |
After our offline discussion yesterday, we've agreed that returning HTTP 404 is the right thing to do. However, I think ideally we could avoid having a new attribute, by always auto-generating a private It means we always do the right thing. WDYT? |
/cc @Deuchnord on this problem:
Is the output model missing even when there's another operation that uses it (including in the case of embedded relations)? If so, it sounds like a bug in the Swagger |
Also somehow related #2954 |
Because in API Platform (and when following the web architecture in general), it's better to identify every resources using an IRI, it's what does API Platform by default. While not mandatory, it's also considered a best practice for an IRI to be "dereferencable". When requesting the IRI, a representation of the resource, or the associated documentation should be displayed.
However, sometimes, you need to use reference to resources that aren't publicly available. Because API Platform internally uses the Symfony router to map objects to URL (forth and back), a route must exist for any resource type exposed through the API (or, in PHP term, for any class marked with
@ApiResource
). A common problem with API Platform is that because of this theGET
operation must always exist, but sometimes you don't want this route (used to generate IRIs) to return anything. In this case, also want to this route to be hidden from the OpenAPI documentation, because it is useless for humans and code generator. This kind of routes are just placeholders used to generate identifiers.My proposal is to introduce a new operation attribute, called
iriOnly
. When set to true, the route will exist but will return a 404 not found status code, and no PHP code, nor SQL request will be triggered. Also, such operations will be automatically hidden from OpenAPI and Swagger documentations. Optionally, a HTTP status code could be associated with this attribute, such asiriOnly=204
.The text was updated successfully, but these errors were encountered: