Skip to content

Commit ae7a4f3

Browse files
committed
Update openapi-fetch, add docs sitemap (#1108)
1 parent 8c1a4a8 commit ae7a4f3

File tree

14 files changed

+180
-41
lines changed

14 files changed

+180
-41
lines changed

docs/astro.config.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { defineConfig } from "astro/config";
22
import preact from "@astrojs/preact";
33
import react from "@astrojs/react";
4+
import sitemap from "@astrojs/sitemap";
45

56
// https://astro.build/config
67
export default defineConfig({
7-
integrations: [preact(), react()],
8-
site: `https://openapi-typescript.pages.dev`,
8+
integrations: [preact(), react(), sitemap()],
9+
site: `https://openapi-ts.pages.dev`,
910
vite: {
1011
define: {
1112
"import.meta.env.VITE_ALGOLIA_APP_ID": JSON.stringify(process.env.ALGOLIA_APP_ID ?? ""),

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"sass": "^1.62.1"
2222
},
2323
"devDependencies": {
24+
"@astrojs/sitemap": "^1.3.1",
2425
"@types/node": "^20.1.1",
2526
"html-escaper": "^3.0.3",
2627
"typescript": "^5.0.4"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
google-site-verification: googlec446be7f016b2162.html

docs/src/components/HeadCommon.astro

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@
22
import "../styles/app.scss";
33
---
44

5-
<!-- Global Metadata -->
65
<meta charset="utf-8" />
76
<meta name="viewport" content="width=device-width" />
87
<meta name="generator" content={Astro.generator} />
98
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
10-
<link rel="sitemap" href="/sitemap.xml" />
11-
12-
<!-- Scrollable a11y code helper -->
9+
<link rel="sitemap" href="/sitemap-index.xml" />
1310
<script src="/make-scrollable-code-focusable.js" is:inline></script>
14-
15-
<!-- This is intentionally inlined to avoid FOUC -->
1611
<script is:inline>
1712
const root = document.documentElement;
1813
const theme = localStorage.getItem("theme");
@@ -22,12 +17,3 @@ import "../styles/app.scss";
2217
root.classList.remove("theme-dark");
2318
}
2419
</script>
25-
26-
<!-- Global site tag (gtag.js) - Google Analytics -->
27-
<!-- <script async src="https://www.googletagmanager.com/gtag/js?id=G-TEL60V1WM9" is:inline></script>
28-
<script>
29-
window.dataLayer = window.dataLayer || [];
30-
function gtag(){dataLayer.push(arguments);}
31-
gtag('js', new Date());
32-
gtag('config', 'G-TEL60V1WM9');
33-
</script> -->

docs/src/components/HeadSEO.astro

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ const canonicalImageSrc = new URL(imageSrc, Astro.site);
1111
const imageAlt = image?.alt ?? OPEN_GRAPH.image.alt;
1212
---
1313

14-
<!-- Page Metadata -->
1514
<link rel="canonical" href={canonicalUrl} />
16-
17-
<!-- OpenGraph Tags -->
1815
<meta property="og:title" content={formattedContentTitle} />
1916
<meta property="og:type" content="article" />
2017
<meta property="og:url" content={canonicalUrl} />
@@ -23,18 +20,9 @@ const imageAlt = image?.alt ?? OPEN_GRAPH.image.alt;
2320
<meta property="og:image:alt" content={imageAlt} />
2421
<meta name="description" property="og:description" content={description ?? SITE.description} />
2522
<meta property="og:site_name" content={SITE.title} />
26-
27-
<!-- Twitter Tags -->
2823
<meta name="twitter:card" content="summary_large_image" />
2924
<meta name="twitter:site" content={OPEN_GRAPH.twitter} />
3025
<meta name="twitter:title" content={formattedContentTitle} />
3126
<meta name="twitter:description" content={description ?? SITE.description} />
3227
<meta name="twitter:image" content={canonicalImageSrc} />
3328
<meta name="twitter:image:alt" content={imageAlt} />
34-
35-
<!--
36-
TODO: Add json+ld data, maybe https://schema.org/APIReference makes sense?
37-
Docs: https://developers.google.com/search/docs/advanced/structured-data/intro-structured-data
38-
https://www.npmjs.com/package/schema-dts seems like a great resource for implementing this.
39-
Even better, there's a React component that integrates with `schema-dts`: https://github.com/google/react-schemaorg
40-
-->

docs/src/components/Header/Search.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/** @jsxImportSource react */
22
import { useState, useCallback, useRef } from "react";
33
import "@docsearch/css";
4-
import "./Search.css";
5-
6-
import { createPortal } from "react-dom";
74
import * as docSearchReact from "@docsearch/react";
5+
import { createPortal } from "react-dom";
6+
import "./Search.css";
87

98
/** FIXME: This is still kinda nasty, but DocSearch is not ESM ready. */
109
const DocSearchModal = docSearchReact.DocSearchModal || (docSearchReact as any).default.DocSearchModal;

docs/src/components/LeftSidebar/LeftSidebar.astro

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
---
2-
import { SIDEBAR } from "../../consts.js";
3-
42
type Props = {
53
currentPage: string;
64
};

docs/src/layouts/MainLayout.astro

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ type Props = CollectionEntry<"docs">["data"] & {
1515
headings: MarkdownHeading[];
1616
};
1717
18+
interface Link {
19+
url: string;
20+
text: string;
21+
}
22+
1823
const { headings, ...data } = Astro.props;
1924
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
2025
const currentPage = Astro.url.pathname;
@@ -131,7 +136,7 @@ const nextLink: Record<string, Link | undefined> = {
131136
<slot />
132137
{currentPage === "/about" && <Contributors usernames={OPENAPI_TS_CONTRIBUTORS} />}
133138
{currentPage === "/openapi-fetch/about" && <Contributors usernames={OPENAPI_FETCH_CONTRIBUTORS} />}
134-
{nextLink[currentPage] && <NextLink href={nextLink[currentPage].url}>{nextLink[currentPage].text}</NextLink>}
139+
{nextLink[currentPage] && <NextLink href={nextLink[currentPage]!.url}>{nextLink[currentPage]!.text}</NextLink>}
135140
</PageContent>
136141
</div>
137142
<aside id="grid-right" class="grid-sidebar" title="Table of Contents">

packages/openapi-fetch/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# openapi-fetch
22

3+
## 0.1.4
4+
5+
### Patch Changes
6+
7+
- 63ebe48: Fix request body type when optional (#48)
8+
9+
## 0.1.3
10+
11+
### Patch Changes
12+
13+
- 8c01480: Fix querySerializer signature
14+
315
## 0.1.2
416

517
### Patch Changes

packages/openapi-fetch/src/index.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,42 @@ describe("post()", () => {
351351
// assert error is empty
352352
expect(error).toBe(undefined);
353353
});
354+
355+
it("request body type when optional", async () => {
356+
fetchMocker.mockResponse(() => ({ status: 201, body: "{}" }));
357+
const client = createClient<paths>();
358+
359+
// expect error on wrong body type
360+
// @ts-expect-error
361+
await client.post("/post/optional", { body: { error: true } });
362+
363+
// (no error)
364+
await client.post("/post/optional", {
365+
body: {
366+
title: "",
367+
publish_date: 3,
368+
body: "",
369+
},
370+
});
371+
});
372+
373+
it("request body type when optional inline", async () => {
374+
fetchMocker.mockResponse(() => ({ status: 201, body: "{}" }));
375+
const client = createClient<paths>();
376+
377+
// expect error on wrong body type
378+
// @ts-expect-error
379+
await client.post("/post/optional/inline", { body: { error: true } });
380+
381+
// (no error)
382+
await client.post("/post/optional/inline", {
383+
body: {
384+
title: "",
385+
publish_date: 3,
386+
body: "",
387+
},
388+
});
389+
});
354390
});
355391

356392
describe("delete()", () => {

0 commit comments

Comments
 (0)