Skip to content

Commit ab560c4

Browse files
Add API Reference (#253)
1 parent 524056b commit ab560c4

18 files changed

Lines changed: 502 additions & 101 deletions

File tree

docs/api/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The notifications can be configured using Webhook or Websocket.
2323

2424
### REST API
2525

26-
[Server OpenAPI](https://github.com/fishjam-cloud/documentation/tree/main/static/api/fishjam-server-openapi.yaml)
26+
[Server REST API Reference](/api/rest)
2727

2828
### Protobufs
2929

docs/how-to/backend/server-setup.mdx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,45 @@ Install the SDK for the language of your choice. We provide libraries for [**Nod
1414
It's also possible to use the bare REST API, in this case you can skip this step.
1515

1616
<Tabs groupId="sdk">
17-
<TabItem value="npm" label="NPM">
17+
<TabItem value="npm" label="npm">
1818

1919
```bash
2020
npm install @fishjam-cloud/js-server-sdk
2121
```
2222

2323
</TabItem>
2424

25-
<TabItem value="yarn" label="YARN">
25+
<TabItem value="yarn" label="yarn">
2626

2727
```bash
2828
yarn add @fishjam-cloud/js-server-sdk
2929
```
3030

3131
</TabItem>
3232

33-
<TabItem value="pip" label="PIP">
33+
<TabItem value="pip" label="pip">
3434

3535
```bash
3636
pip install fishjam-server-sdk
3737
```
3838

3939
</TabItem>
4040

41-
<TabItem value="poetry" label="POETRY">
41+
<TabItem value="poetry" label="poetry">
4242

4343
```bash
4444
poetry add fishjam-server-sdk
4545
```
4646

4747
</TabItem>
48+
49+
<TabItem value="uv" label="uv">
50+
51+
```bash
52+
uv add fishjam-server-sdk
53+
```
54+
55+
</TabItem>
4856
</Tabs>
4957

5058
## Setup your client

docs/tutorials/backend-quick-start.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ A simple backend server that can create rooms, add peers, and generate tokens fo
114114
```
115115

116116
</TabItem>
117+
118+
<TabItem value="uv" label="uv">
119+
120+
```bash
121+
uv add fishjam-server-sdk
122+
```
123+
124+
</TabItem>
117125
</Tabs>
118126

119127
</TabItem>
@@ -395,6 +403,14 @@ Build a simple HTTP endpoint that your client apps can call:
395403
```
396404

397405
</TabItem>
406+
407+
<TabItem value="uv" label="uv">
408+
409+
```bash
410+
uv add fastapi[standard]
411+
```
412+
413+
</TabItem>
398414
</Tabs>
399415

400416
</TabItem>

docusaurus.config.ts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { Config } from "@docusaurus/types";
22
import type * as Preset from "@docusaurus/preset-classic";
33
import type { UserThemeConfig as DocSearchThemeConfig } from "@docsearch/docusaurus-adapter";
4+
import type { ScalarOptions } from "@scalar/docusaurus";
45
import { BundledLanguage, bundledLanguages } from "shiki";
56
import type { MDXPlugin } from "@docusaurus/mdx-loader";
67
import rehypeShiki, { RehypeShikiOptions } from "@shikijs/rehype";
7-
import { removeTwoslashNotations } from "twoslash";
88
import {
99
transformerMetaHighlight,
1010
transformerNotationDiff,
@@ -241,6 +241,21 @@ const config: Config = {
241241
src: "img/logo.svg",
242242
},
243243
items: [
244+
{
245+
type: "doc",
246+
docId: "index",
247+
label: "Docs",
248+
position: "left",
249+
},
250+
{
251+
to: "/api/rest",
252+
label: "API Reference",
253+
position: "left",
254+
},
255+
{
256+
type: "docsVersionDropdown",
257+
position: "right",
258+
},
244259
{
245260
href: "https://fishjam.io/app/",
246261
label: "Fishjam Dashboard",
@@ -251,9 +266,6 @@ const config: Config = {
251266
label: "GitHub",
252267
position: "right",
253268
},
254-
{
255-
type: "docsVersionDropdown",
256-
},
257269
],
258270
},
259271
docsearch: {
@@ -313,6 +325,23 @@ const config: Config = {
313325
plugins: [
314326
["@docusaurus/plugin-client-redirects", { createRedirects }],
315327
"@docsearch/docusaurus-adapter",
328+
[
329+
"@scalar/docusaurus",
330+
{
331+
label: "Server REST API",
332+
route: "/api/rest",
333+
showNavLink: false,
334+
configuration: {
335+
url: "/docs/api/fishjam-server-openapi.yaml",
336+
hideSearch: true,
337+
persistAuth: true,
338+
defaultOpenFirstTag: false,
339+
authentication: {
340+
preferredSecurityScheme: "management_token",
341+
},
342+
},
343+
} as ScalarOptions,
344+
],
316345
[
317346
"docusaurus-plugin-typedoc",
318347
{

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@
3131
"@docusaurus/preset-classic": "^3.10.0",
3232
"@docusaurus/remark-plugin-npm2yarn": "^3.10.0",
3333
"@docusaurus/theme-mermaid": "^3.10.0",
34+
"@docusaurus/utils": "^3.10.0",
3435
"@fastify/env": "^5.0.2",
3536
"@fishjam-cloud/js-server-sdk": "link:./packages/js-server-sdk/packages/js-server-sdk",
3637
"@fishjam-cloud/react-client": "link:./packages/web-client-sdk/packages/react-client",
3738
"@fishjam-cloud/react-native-client": "link:./packages/web-client-sdk/packages/mobile-client",
3839
"@mdx-js/react": "^3.1.0",
40+
"@scalar/docusaurus": "^0.8.5",
3941
"@shikijs/rehype": "^3.6.0",
4042
"@shikijs/transformers": "^3.6.0",
4143
"@swmansion/smelter": "^0.2.1",

src/css/custom.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,19 @@
2828
--ifm-color-primary-lightest: #4fddbf;
2929
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
3030
}
31+
3132
html[data-theme="light"] body {
3233
color: #221f1c;
3334
}
35+
3436
html[data-theme="light"] footer.footer {
3537
background-color: #fcf4e4;
3638
}
39+
3740
html[data-theme="light"] nav.navbar--fixed-top {
3841
background-color: #fcf4e4;
3942
}
43+
4044
html[data-theme="light"] header.heroBanner_src-pages-index-module {
4145
background-color: #9bdcfb;
4246
color: #221f1c;
@@ -64,6 +68,10 @@ html[data-theme="light"] header.heroBanner_src-pages-index-module {
6468
vertical-align: middle;
6569
}
6670

71+
.scalar-api-reference .badge {
72+
text-transform: unset;
73+
}
74+
6775
.badge--web {
6876
background-color: #3578e5;
6977
color: white;
@@ -114,3 +122,28 @@ extra spacing keeps it from overlapping with cookies button */
114122
}
115123

116124
@import url("./_shiki.css");
125+
126+
/* Align the Scalar API reference typography with the rest of the docs. */
127+
:root {
128+
--scalar-font-size-1: var(--ifm-h3-font-size);
129+
--scalar-font-size-2: var(--ifm-h4-font-size);
130+
--scalar-font-size-3: 0.9375rem;
131+
--scalar-font-size-4: 0.9rem;
132+
--scalar-font-size-5: 0.85rem;
133+
--scalar-font-size-6: 0.8rem;
134+
--scalar-font-size-7: 0.75rem;
135+
136+
--scalar-paragraph: 0.9375rem;
137+
--scalar-small: 0.9rem;
138+
--scalar-mini: 0.75rem;
139+
140+
--scalar-heading-1: var(--ifm-h1-font-size);
141+
--scalar-heading-2: var(--ifm-h2-font-size);
142+
--scalar-heading-3: var(--ifm-h3-font-size);
143+
--scalar-heading-4: var(--ifm-h4-font-size);
144+
--scalar-heading-5: var(--ifm-h5-font-size);
145+
--scalar-heading-6: var(--ifm-h6-font-size);
146+
147+
--scalar-font: var(--ifm-font-family-base);
148+
--scalar-font-code: var(--ifm-font-family-monospace);
149+
}

src/theme/NavbarItem/index.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from "react";
2+
import { useLocation } from "@docusaurus/router";
3+
import useBaseUrl from "@docusaurus/useBaseUrl";
4+
import OriginalNavbarItem from "@theme-original/NavbarItem";
5+
6+
type NavbarItemProps = React.ComponentProps<typeof OriginalNavbarItem>;
7+
8+
export default function NavbarItemWrapper(
9+
props: NavbarItemProps,
10+
): React.JSX.Element | null {
11+
const { pathname } = useLocation();
12+
const apiReferenceUrl = useBaseUrl("/api/rest");
13+
const isDocsVersionDropdown = props.type === "docsVersionDropdown";
14+
const isApiReferencePage = pathname.startsWith(apiReferenceUrl);
15+
16+
// The Scalar REST reference is unversioned, so we hide the version dropdown
17+
if (isDocsVersionDropdown && isApiReferencePage) {
18+
return null;
19+
}
20+
21+
return <OriginalNavbarItem {...props} />;
22+
}

0 commit comments

Comments
 (0)