Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi committed Dec 11, 2024
1 parent ef8c601 commit 31365c0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ navigation:
icon: fa-regular fa-file
path: ./pages/api-definition/openapi/endpoints/multipart.mdx
slug: multipart
- page: Bytes
path: ./pages/api-definition/openapi/endpoints/bytes.mdx
icon: fa-regular fa-server
slug: bytes
- page: Server Sent Events
path: ./pages/api-definition/openapi/endpoints/sse.mdx
icon: fa-regular fa-signal-stream
Expand Down
55 changes: 55 additions & 0 deletions fern/pages/api-definition/fern-definition/endpoints/bytes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Binary Data and Files
subtitle: Use the `bytes` type to handle binary data in your API
---

<Note>
The `bytes` type allows you to handle binary data in both requests and responses.
</Note>

## Sending bytes

If your API needs to send a stream of bytes (i.e. typical for assets like audio, images and other files) then
you can use the `bytes` type in the Fern Definition to model this.

```yml audio.yml
service:
base-path: /audio
endpoints:
upload:
display-name: Upload audio
method: POST
path: /upload
content-type: application/octet-stream
request:
type: bytes
docs: The bytes of the MP3 file that you would like to upload
```
## Receiving bytes
On the other hand, if your API is returning a stream of bytes, then you can leverage the `bytes` type as a response.

```yml textToSpeech.yml
service:
base-path: /tts
endpoints:
upload:
display-name: Upload audio
method: POST
path: ""
request:
name: TTSRequest
body:
properties:
text:
type: string
docs: The text that you want converted to speach.
response:
type: bytes
docs: The bytes of the audio file.
```




0 comments on commit 31365c0

Please sign in to comment.