Giter VIP home page Giter VIP logo

Comments (3)

kylef avatar kylef commented on May 30, 2024

That's because it describes a request-response pair. If you want multiple request-response pairs then you could have multiple httpTransactions.

The exampleโ€™s content consist of a request-response message pair. A transaction example MUST contain exactly one HTTP request and one HTTP response message.

from api-elements.

avigoldman avatar avigoldman commented on May 30, 2024

Is there a way to have a single request with multiple sample responses?

from api-elements.

kylef avatar kylef commented on May 30, 2024

The idea is, you would provide the request which would cause that specific response. I would gather that your implementation won't randomly provide different responses with same request. It is likely that a request parameter, header or request message body etc would cause the different response. So you would have a different request example which would produce that response. The only exception to this would be infrastructure problems and such where you could get 5xx error codes. The other case may be due to idempotency when calling the same request twice produces different response. For example calling DELETE twice on a resource where first time there is success and second time causes a 404 because it is already deleted. That said, it is probably clearer in your examples to use separate requests which produce it for example a request to delete an existing resource and a separate request example of deleting an already-deleted resource or a resource that doesn't exist.

Here's an example, in API Blueprint where a request with one Authorization header value causes error and when I provide a valid Authorization header I receive a success:

+ Request

    + Headers

            Authorization: invalid token

+ Response 403

+ Request

    + Headers

            Authorization: valid token

+ Response 204

from api-elements.

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.