bruno
bruno copied to clipboard
Save Response Examples
This feature was mentioned in Bruno Road map. I would like to work on it.
While doing this features. One question arises where should I store examples of a particular request, there are following option:
- .bru file of each request (examples array)
- Create A JSON for a collection storing with seq number so that they can be mapped.
- Create a seprate json for each request. @helloanoop @Its-treason Can you help to suggest which way should I do it or any other suggestion.
The response examples for each request will be stored inside the .bru
file itself
This should be possibly once the Bru Lang is live. Here is how it would look like
http: {
method: 'GET'
url: 'https://www.usebruno.com/login'
headers: {
Accept: 'application/json'
}
body: {
type: json
data: '''
{
"username": "bruno",
"password": "secret",
}
'''
}
@status(200)
@description('Login successful')
response: {
headers: {
Content-Type: 'application/json'
}
data: '''
{
"status": true
}
'''
}
@status(401)
@description('Login failed')
response: {
headers: {
Content-Type: 'application/json'
}
data: '''
{
"status": false
}
'''
}
}
okay, I will be working on this feature when Bru Lang is live.
I think it should like this we need to have Id for each example and we need to also store request data sent at that time, later on it might change in future.
http: {
method: 'GET'
url: 'https://www.usebruno.com/login'
headers: {
Accept: 'application/json'
}
body: {
type: json
data: '''
{
"username": "bruno",
"password": "secret",
}
'''
}
@id(1)
@status(200)
@description('Login successful')
response: {
headers: {
Content-Type: 'application/json'
}
data: '''
{
"status": true
}
'''
}
request: {
headers: {
Content-Type: 'application/json'
}
body: '''
{
"status": true
}
'''
... method, url,parama
}
@id(2)
@status(401)
@description('Login failed')
response: {
headers: {
Content-Type: 'application/json'
}
data: '''
{
"status": false
}
'''
}
}
request: {
headers: {
Content-Type: 'application/json'
}
body: '''
{
"status": true
}
'''
... method, url,parama
}
Hi, will this feature might be released anytime soon? We're exploring postman alternatives at the moment and the feature to save examples is one of our top priorities.
+1. Response examples are a hygiene feature
Also, piggy backing off of this idea (using Docs tab for response examples), it would be great to allow including content from other files using markdown-it-include.
What the .bru would look like:
docs {
Response examples:
!!!include(example1.md)!!!
!!!include(example2.md)!!!
}
This looks like a great workaround to have till we get the response examples feature
+1 for this feature. Saving response is handy, as you can't always hit API, especially for POST & PUT. Makes thing easy to debug.
@helloanoop Why does it need to have a different response for each status code stored? Shouldn't a call be reproducable, so that it should have only one possible response? I also think it would make more sense to simply redirect the output to a file with the same name in the same directory, that simply has a different extension.
test.bru
could store the response in test.out
or whatever. (to be discussed, out
probably has high collision potential)
This could be an opt-in feature, out
files could be excluded from version control, for those who wish to inspect the output in a different editor, but not have it be part of the repo. On top of that it could work well for the issue linked by @tsriram if output could also be suppressed in Bruno itself.
@helloanoop @akshat-khosya, I'd like to pick this up if no one is already working on it.
This is a fairly complex feature considering that the bru lang would need updates.
We are considering to move to yaml
as a standard to makes things easier.
This will take more time. We will revisit this and setout an approach once we release initial support for yaml
storage in Bruno