Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 514d2ff

Browse files
committed
docs: add docs on binary bodies
1 parent b0106d1 commit 514d2ff

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

docs/how-it-works.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ If there is no body example or schema specified for the response in your API des
154154

155155
If you want to enforce the incoming body is empty, you can use [hooks](hooks.md):
156156

157-
```js
157+
```javascript
158158
:[hooks example](../test/fixtures/response/empty-body-hooks.js)
159159
```
160160

docs/how-to-guides.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,38 @@ Most of the authentication schemes use HTTP header for carrying the authenticati
523523
:[Swagger example](../test/fixtures/request/application-x-www-form-urlencoded.yaml)
524524
```
525525

526+
## Working with Images and other Binary Bodies
527+
528+
The API description formats generally do not provide a way to describe binary content. The easiest solution is to describe only the media type, to [leave out the body](how-it-works.md#empty-response-body), and to handle the rest using [hooks](hooks.md).
529+
530+
### API Blueprint
531+
532+
```apiblueprint
533+
:[API Blueprint example](../test/fixtures/response/binary.apib)
534+
```
535+
536+
### Swagger
537+
538+
```yaml
539+
:[Swagger example](../test/fixtures/response/binary.yaml)
540+
```
541+
542+
> **Note:** Do not use the explicit `binary` or `bytes` formats with response bodies, as Dredd is not able to properly work with those ([fury-adapter-swagger#193](https://github.com/apiaryio/fury-adapter-swagger/issues/193)).
543+
544+
### Hooks
545+
546+
In hooks, you can either assert the body:
547+
548+
```javascript
549+
:[Hooks example](../test/fixtures/response/binary-assert-body-hooks.js)
550+
```
551+
552+
Or you can ignore it:
553+
554+
```javascript
555+
:[Hooks example](../test/fixtures/response/binary-ignore-body-hooks.js)
556+
```
557+
526558
## Multiple Requests and Responses
527559

528560
> **Note:** For details on this topic see also [How Dredd Works With HTTP Transactions](how-it-works.md#choosing-http-transactions).

0 commit comments

Comments
 (0)