Closed bjornharrtell closed 7 years ago
@bjornharrtell I have a related type of issue. In our app we have one route that we would like to serve without requiring application/vnd.api+json
Accept header. For my solution, I was thinking adding additional logic to ReturnsResourceAttribute to effectively turn off that requirement.
ReturnsResourceAttribute constructor:
public ReturnsResourceAttribute(Type resourceType, bool disableJsonApiFilter = false)
Usage:
[Route("api/attachments/{id}/download")]
[ReturnsResource(typeof(AttachmentResource), disableJsonApiFilter: true)]
public async Task<HttpResponseMessage> DownloadAttachment(int id)
{
...// etc.
While I don't expect that you would decorate all your DELETE actions this way, perhaps there is some common ground here. @joukevandermaas, curious if you've thought about this at all.
It's similar to https://github.com/joukevandermaas/saule/issues/100. I hope to be able to contribute a PR to fix it eventually.
@adamalesandro In my understanding, the spec says it's required if the client is talking to a JSON API server. There should be a way to 'turn off' Saule for specific endpoints, but then it should also turn off serialization IMO. I'm curious about your use-case, though.
@bjornharrtell I think Saule should not require the content-type
header for any request without content (including DELETE
of course), I think. At least, this makes sense to me :smile:
Agreed @joukevandermaas. I think @adamalesandro is also talking about requests without content.
Yes, correct. In our case we want to return a file (as download) from an href link in an ember app.
I should also add that I'm new to ember/JSON-API so if there's an already accepted way of serving files, I'd go that way. I have not come across anything viable from my research yet.
I was refering to posting (or patching) content to the server. Delivering content from the server anything else than application/vnd.api+json
isn't JSON API, so I'd say Saule should not be involved - just make an ordinary Web API 2 controller.
@adamalesandro I see you are refering to both Accept
and Content-Type
headers which is confusing.
In my understanding the mime type for both should be application/vnd.api+json
but is optional for requests/responses without body. A DELETE
response may contain a body and in that case it will be a top level meta data for the deleted entities. See http://jsonapi.org/format/#crud-deleting.
@bjornharrtell Well that's embarrassing. I was so caught up with how to make this work with saule, I never even thought of making a separate controller.
Fixed with #151.