Giter Club home page Giter Club logo

Comments (6)

jozsefsallai avatar jozsefsallai commented on May 29, 2024 7

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.

jozsefsallai avatar jozsefsallai commented on May 29, 2024 5

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:

image

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.

WinterCore avatar WinterCore commented on May 29, 2024 2

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.

vinimello avatar vinimello commented on May 29, 2024 1

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.

tiagopaes avatar tiagopaes commented on May 29, 2024

I think it is a great ideia!

from insomnia-documenter.

shamscorner avatar shamscorner commented on May 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.