Giter Site home page Giter Site logo

Comments (12)

jozsefsallai avatar jozsefsallai commented on May 20, 2024 5

Experimental support for example responses has been added. It features syntax highlighting too (though to be honest, I've only tested that with JSON 😅). It's now available in v0.3.0! Here's what it looks like:

image

All you have to do is to enclose the example response between <!-- RESPONSE --> and <!-- ENDRESPONSE --> tags. This only works with one example. Any other example responses will be ignored.

Any thoughts, ideas, suggestions about this implementation?

(cc @ZarifS @lramosduarte)

from insomnia-documenter.

jozsefsallai avatar jozsefsallai commented on May 20, 2024 3

Yes, you can add as many as you want and you can also specify the status code (see: #16 (comment)).

However, the syntax is going to change in a future release (see #30).

from insomnia-documenter.

jozsefsallai avatar jozsefsallai commented on May 20, 2024 1

@gschier Fair enough! I can see why this wouldn't be ideal, yeah.

@ZarifS I will research into ways to making this workable. Until I can come up with a better solution, a good workaround would be to include the example response in the description of the request.

from insomnia-documenter.

lramosduarte avatar lramosduarte commented on May 20, 2024 1

Thanks @jozsefsallai , i ll test this later.

It looks like very interesting

from insomnia-documenter.

jozsefsallai avatar jozsefsallai commented on May 20, 2024

Hey! Thank you for the kind words! :)

At the moment, Insomnia export files don't contain the server response, so there isn't really a way to do this (well, apart from running the requests on runtime but that would make the page slow and it will probably not work every time)! Maybe if @gschier can make it so that the response will also be exported, I could make it work with the documenter. 👀

from insomnia-documenter.

gschier avatar gschier commented on May 20, 2024

Would definitely be possible to implement in Insomnia but I'm not sure that's ideal. It seems like @ZarifS wants to be able to specify an example response manually?

from insomnia-documenter.

ZarifS avatar ZarifS commented on May 20, 2024

Yes exactly! For example showcasing the JSON response that would be expected from doing a call with certain parameters.

Say "/get/users" -> shows a response on the documenter showcasing the response that would be expected like a json body of what the server would send back.

This way anyone looking at the documentation will also known what the response would look like, hence making developing with that API much easier in the case of mocking it for example.

from insomnia-documenter.

gschier avatar gschier commented on May 20, 2024

I wonder if we could use HTML comments in the request description to designate that it's a response. Then documented could look for those comments and deal with them accordingly

from insomnia-documenter.

jozsefsallai avatar jozsefsallai commented on May 20, 2024

Yeah, I was thinking of a similar implementation. 👍

from insomnia-documenter.

jozsefsallai avatar jozsefsallai commented on May 20, 2024

Closing for inactivity/tidying up!

from insomnia-documenter.

bediu avatar bediu commented on May 20, 2024

Is there a way to add multiple response types from one request?

from insomnia-documenter.

bediu avatar bediu commented on May 20, 2024

@jozsefsallai

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.