multiple responses rendered as multiple requests
Closed this issue · 3 comments
For example, the two responses of the first request of
https://apiblueprint.org/documentation/examples/05-responses.html
are rendered as two requests.
Instead, they should be rendered as two responses under the same request.
Otherwise, great project!
I don't know if it is still relevant for you, I created a gist with some minor adjustments so responses are rendered within a request. The thing is, that your requests need a title so they may be grouped together.
https://gist.github.com/MelzerC/530201b0e1f7206ad80543bb6cc9129b
Relevant lines are:
winter.svelte:90-119 - grouping transactions based on the request title
winter.svelte:591-599 - use the generated request groups to display scenarios
ScenarioPanel.svelte: change response property to responses, add a loop for the responses.
ResponsePanel.svelte:16-20 - add a spacing between the responses.
Thanks for your reply!
I tried it but still could not get the grouping to work...
Could you post an example of what you mean by "your requests need a title"?
I tried:
+ Request Title1
+ Headers
Accept: application/json
+ Response 200 (application/json)
{ ... }
+ Request Title1
+ Response 403
+ Request Title1
+ Response 404
Sorry for not being clear on this one. You still format your Blueprint file as before. So you would have something like this:
+ Request Title1
+ Headers
[...]
+ Response 200 (application/json)
{...}
+ Response 403 (application/json)
+ Response 404 (application/json)
Snowboard will generate a json object out of your blueprint file (you'll find a minified version by searching for your title within the generated html file) containing something looking like this:
{
[...]
"transactions": [
{
"request": {"title": "Title1", ...},
"response": {"status": 200, ...},
},
{
"request": {"title": "Title1"},
"response": {"status": 403, ...},
},
{
"request": {"title": "Title1"},
"response": {"status": 404, ...},
},
{
"request": {"title": "Title2"},
"response": {"status": 200, ...},
},
]
}
My changes in the gist basically loop over the transactions and storing a grouped version within a different property. To do the grouping I access the title of every transaction request.
Please note: I'm not doing any checks if the title exists and stuff so the script is not failsafe. If you like to change the logic, have a look at winter.svelte
lines 90-116
in my gist (https://gist.github.com/MelzerC/530201b0e1f7206ad80543bb6cc9129b#file-winter-svelte-L90-L117). This function defines how the grouping works.