Comments (6)
I'm thinking of ways to implement this. Perhaps something like this could work:
<!-- RESPONSE 200 -->
<!-- ENDRESPONSE -->
<!-- RESPONSE 401 -->
<!-- ENDRESPONSE -->
and for backwards-compatibility:
<!-- RESPONSE -->
<!-- ENDRESPONSE -->
a regular expression could match either of these and capture both the example response and the status code
from insomnia-documenter.
Good news, everyone! I've added support for this :) You can have as many responses as you want now and you can also specify the status code for each and every one of them!
The old <!-- RESPONSE -->
and <!-- ENDRESPONSE -->
method still works, it will just not display a status code at all.
The color of the header and the border will indicate the type of request:
- 1xx (info) - blue
- 2xx (success) - green
- 3xx (redirect) - brown
- 4xx (client error) - orange
- 5xx (server error) - red
- everything else - Insomnia purple
Here's what it looks like in action:
The description of the new section in the demo looks like this:
You can specify multiple example responses -- now with status codes! Instead of `<!-- RESPONSE -->` you can write `<!-- RESPONSE 200 -->`. You still have to close it using `<!-- ENDRESPONSE -->` though!
<!-- RESPONSE 200 -->
{
"ok": true,
"token": "123abc"
}
<!-- ENDRESPONSE -->
<!-- RESPONSE 400 -->
{
"ok": false,
"error": "Username or password not provided."
}
<!-- ENDRESPONSE -->
<!-- RESPONSE 401 -->
{
"ok": false,
"error": "Incorrect username and/or password."
}
<!-- ENDRESPONSE -->
Hope you guys find it useful and if you have any questions or suggestions, feel free to comment on this issue!
from insomnia-documenter.
Even though this is a bit late.
For whoever's wondering where to put the example responses.
You put them in the Docs
tab of the request.
I honestly think this should be included in the README, because it was a little confusing.
from insomnia-documenter.
Hey guys, first of all thanks for the awesome documenter! I have a question, where do i put this tags with the response to show the block in my documentation? Is it in the json archive? In the docs in insomnia before exporting? I couldnt find where i put the tags, every place i tried it didnt work. Thanks for the help!
<!-- ENDRESPONSE -->
~~response~~
<!-- RESPONSE -->
from insomnia-documenter.
I think it is a great ideia!
from insomnia-documenter.
Great! I loved it and really appreciate that. But I have one recommendation here. For API, most of the requests are,
-
GET - 200 (success)
-
POST - 201 (created)
-
PATCH - 200 (success)
-
DELETE - 204 (no content)
-
NOT FOUND - 404
-
UNAUTHORIZED - 401
-
FORBIDDEN - 403
-
METHOD NOT ALLOWED - 405
-
NOT ACCEPTABLE - 406
-
BAD REQUEST - 400
-
INTERNAL SERVER ERROR - 500
-
BAD GATEWAY - 502
Did you get my point? I've just got 3 colors so far you know. Instead of getting the colors programmatically from the specified status code, you can make those variables (blue, green, brown, orange, red, etc) user-defined. Something like this,
<!-- RESPONSE 200 green-->
{
"ok": true,
"token": "123abc"
}
<!-- ENDRESPONSE -->
<!-- RESPONSE 400 orange -->
{
"ok": false,
"error": "Username or password not provided."
}
<!-- ENDRESPONSE -->
<!-- RESPONSE 500 red -->
{
"ok": false,
"error": "Incorrect username and/or password."
}
<!-- ENDRESPONSE -->
In that way, users will have more freedom. 🙂
from insomnia-documenter.
Related Issues (20)
- Error displaying app HOT 14
- Python request display HOT 1
- cannot access insomnia,json HOT 2
- For support use Discussions, for bug reports use Issues! HOT 4
- Option to not include cookies in documentation
- JSON.parse SyntaxError since 0.4.4 HOT 6
- Environment not working HOT 2
- Error in export Json V4 HOT 1
- Push commit to npm HOT 1
- Documentation show error "TypeError: e is null" HOT 2
- FormatEnv function throws an error when url for some requests are empty
- Add `overflow: auto` to description css class
- Example response not parsed HOT 2
- Github Pages Deployment steps
- Example response not working HOT 13
- Raw content data support. HOT 2
- Converting to Static Site
- Auto Expand Menu HOT 1
- Display info.description
- Demo Page 404 on README.md HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from insomnia-documenter.