Comments (3)
That's because it describes a request-response pair. If you want multiple request-response pairs then you could have multiple httpTransaction
s.
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.
Is there a way to have a single request with multiple sample responses?
from api-elements.
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)
- Guidelines on how to use copy and description
- Single API Elements Package HOT 1
- Hypermedia Affordances
- Annotation "fixits" HOT 1
- Remove `annotation` code HOT 7
- Clarify source map type HOT 11
- Support files in Source Map
- Provide information about the source ADD format and version HOT 2
- Document the migration path and changes between API Elements 0.6 and 1.0 HOT 3
- Make `HTTP Headers` an array of `HTTP Header`
- Broken mapping
- Headings have overlapping permalinks
- Link README to production docs HOT 1
- Clarify source map line/column indexing
- Exposing Deployment Information HOT 7
- API Elements evolution process
- Add repo URL for docs HOT 1
- nullable type attribute is undocumented
- Full support for expressing JSON Schema constraints in API Element data structures
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 api-elements.