I am confused how to specify multiple possible reponses in RestXQ with %rest:produces
Monday, 11 May 2020 · 4 messages · last reply 12 May 2020
OS
Omar Siam11 May 2020 15:54 #
Hi,
Today someone on the exist-open mailing list pointed out how they interpret %rest:produces: If your function produces more types of responses you specify all mime types just the same as with
%rest:consumes: %rest:poroduces("application/xml", "application/json", ...) That is as a list of possible reponses all in one annotation.
The BaseX docs at https://docs.basex.org/wiki/RESTXQ#Content_Negotiation however are ambigous about this I think. There is an example there with just two %rest:produces annotations on two lines with only one mime type (and a qs value). I think that lead me to belief that to specify multiple possible responses of different mime types you repeat %rest:produces.
Rereading the section these two example annotations could also ilustrate the use of %rest:produces in two different functions.
Can you please clarify this if possible?
Best regards
Omar Siam
CG
Christian Grün11 May 2020 18:31 #
Hi Omar,
Your question was if multiple mime types need to be specified via a single or multiple annotations, right?
I have added some examples to the Content Negotiation section; I hope it’s more comprehensible now.
Hope this helps,
Christian
Quoted text · Omar Siam · 25 lines
On Mon, May 11, 2020 at 3:54 PM Omar Siam <omar.siam at oeaw.ac.at> wrote: > > Hi, > > Today someone on the exist-open mailing list pointed out how they > interpret %rest:produces: If your function produces more types of > responses you specify all mime types just the same as with > %rest:consumes: %rest:poroduces("application/xml", "application/json", > ...) That is as a list of possible reponses all in one annotation. > > The BaseX docs at https://docs.basex.org/wiki/RESTXQ#Content_Negotiation > however are ambigous about this I think. There is an example there with > just two %rest:produces annotations on two lines with only one mime type > (and a qs value). I think that lead me to belief that to specify > multiple possible responses of different mime types you repeat > %rest:produces. > > Rereading the section these two example annotations could also ilustrate > the use of %rest:produces in two different functions. > > Can you please clarify this if possible? > > Best regards > > Omar Siam
OS
Omar Siam12 May 2020 12:33 #
That is much better now.
There are two further improvement: I think %rest:consumes and %rest:produces can be specified pretty much alike so for both the statement "Multiple types can either be specified by a single or by multiple annotations." is true. Unfortunately you only say that in the subparagraph about Pruducing Data. If I only care about Consuming Data right now I probably will not read this.
Besides the example for consuming data really needs a function parameter else I would start wondering by what magic the content I send in the body is represented in the function.
Best regards
Omar Siam
Quoted text · Christian Grün · 38 lines
Am 11.05.2020 um 18:31 schrieb Christian Grün: > Hi Omar, > > Your question was if multiple mime types need to be specified via a > single or multiple annotations, right? > > I have added some examples to the Content Negotiation section; I hope > it’s more comprehensible now. > > Hope this helps, > Christian > > > > On Mon, May 11, 2020 at 3:54 PM Omar Siam <omar.siam at oeaw.ac.at> wrote: >> Hi, >> >> Today someone on the exist-open mailing list pointed out how they >> interpret %rest:produces: If your function produces more types of >> responses you specify all mime types just the same as with >> %rest:consumes: %rest:poroduces("application/xml", "application/json", >> ...) That is as a list of possible reponses all in one annotation. >> >> The BaseX docs at https://docs.basex.org/wiki/RESTXQ#Content_Negotiation >> however are ambigous about this I think. There is an example there with >> just two %rest:produces annotations on two lines with only one mime type >> (and a qs value). I think that lead me to belief that to specify >> multiple possible responses of different mime types you repeat >> %rest:produces. >> >> Rereading the section these two example annotations could also ilustrate >> the use of %rest:produces in two different functions. >> >> Can you please clarify this if possible? >> >> Best regards >> >> Omar Siam
CG
Christian Grün12 May 2020 12:47 #
Ok, I have done some further minor edits.
Everyone… Edits in our Wiki are welcome. Feel free to get an account!
Quoted text · Omar Siam · 57 lines
On Tue, May 12, 2020 at 12:33 PM Omar Siam <Omar.Siam at oeaw.ac.at> wrote: > > That is much better now. > > There are two further improvement: I think %rest:consumes and > %rest:produces can be specified pretty much alike so for both the > statement "Multiple types can either be specified by a single or by > multiple annotations." is true. Unfortunately you only say that in the > subparagraph about Pruducing Data. If I only care about Consuming Data > right now I probably will not read this. > > Besides the example for consuming data really needs a function parameter > else I would start wondering by what magic the content I send in the > body is represented in the function. > > Best regards > > Omar Siam > > Am 11.05.2020 um 18:31 schrieb Christian Grün: > > Hi Omar, > > > > Your question was if multiple mime types need to be specified via a > > single or multiple annotations, right? > > > > I have added some examples to the Content Negotiation section; I hope > > it’s more comprehensible now. > > > > Hope this helps, > > Christian > > > > > > > > On Mon, May 11, 2020 at 3:54 PM Omar Siam <omar.siam at oeaw.ac.at> wrote: > >> Hi, > >> > >> Today someone on the exist-open mailing list pointed out how they > >> interpret %rest:produces: If your function produces more types of > >> responses you specify all mime types just the same as with > >> %rest:consumes: %rest:poroduces("application/xml", "application/json", > >> ...) That is as a list of possible reponses all in one annotation. > >> > >> The BaseX docs at https://docs.basex.org/wiki/RESTXQ#Content_Negotiation > >> however are ambigous about this I think. There is an example there with > >> just two %rest:produces annotations on two lines with only one mime type > >> (and a qs value). I think that lead me to belief that to specify > >> multiple possible responses of different mime types you repeat > >> %rest:produces. > >> > >> Rereading the section these two example annotations could also ilustrate > >> the use of %rest:produces in two different functions. > >> > >> Can you please clarify this if possible? > >> > >> Best regards > >> > >> Omar Siam
Written for BaseX 9.3. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery