Skip to content

Commit 479721d

Browse files
committed
Fix docs build
1 parent 5f430e3 commit 479721d

File tree

9 files changed

+306
-13
lines changed

9 files changed

+306
-13
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.DS_Store
2-
.astro
32
dist
43
node_modules
54

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ Contributions are appreciated and welcome! See the appropriate guide for each pa
2323
## ♥️ Thanks
2424

2525
- Thanks to [dozens of lovely, smart contributors](https://github.com/drwpow/openapi-typescript/graphs/contributors) that made this library possible
26-
- Thanks to [Astro](https://astro.build/) for the docs site
26+
- Thanks to [Vitepress](https://vitepress.dev/) for the docs site
2727
- Thanks to [Cloudflare Pages](https://pages.cloudflare.com/) for docs site hosting
2828
- Thanks to [Algolia](https://www.algolia.com/) for the docs site search

docs/.astro/types.d.ts

+294
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
declare module 'astro:content' {
2+
interface Render {
3+
'.md': Promise<{
4+
Content: import('astro').MarkdownInstance<{}>['Content'];
5+
headings: import('astro').MarkdownHeading[];
6+
remarkPluginFrontmatter: Record<string, any>;
7+
}>;
8+
}
9+
}
10+
11+
declare module 'astro:content' {
12+
export { z } from 'astro/zod';
13+
14+
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
15+
16+
export type CollectionKey = keyof AnyEntryMap;
17+
export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>;
18+
19+
export type ContentCollectionKey = keyof ContentEntryMap;
20+
export type DataCollectionKey = keyof DataEntryMap;
21+
22+
// This needs to be in sync with ImageMetadata
23+
export type ImageFunction = () => import('astro/zod').ZodObject<{
24+
src: import('astro/zod').ZodString;
25+
width: import('astro/zod').ZodNumber;
26+
height: import('astro/zod').ZodNumber;
27+
format: import('astro/zod').ZodUnion<
28+
[
29+
import('astro/zod').ZodLiteral<'png'>,
30+
import('astro/zod').ZodLiteral<'jpg'>,
31+
import('astro/zod').ZodLiteral<'jpeg'>,
32+
import('astro/zod').ZodLiteral<'tiff'>,
33+
import('astro/zod').ZodLiteral<'webp'>,
34+
import('astro/zod').ZodLiteral<'gif'>,
35+
import('astro/zod').ZodLiteral<'svg'>,
36+
import('astro/zod').ZodLiteral<'avif'>,
37+
]
38+
>;
39+
}>;
40+
41+
type BaseSchemaWithoutEffects =
42+
| import('astro/zod').AnyZodObject
43+
| import('astro/zod').ZodUnion<[BaseSchemaWithoutEffects, ...BaseSchemaWithoutEffects[]]>
44+
| import('astro/zod').ZodDiscriminatedUnion<string, import('astro/zod').AnyZodObject[]>
45+
| import('astro/zod').ZodIntersection<BaseSchemaWithoutEffects, BaseSchemaWithoutEffects>;
46+
47+
type BaseSchema =
48+
| BaseSchemaWithoutEffects
49+
| import('astro/zod').ZodEffects<BaseSchemaWithoutEffects>;
50+
51+
export type SchemaContext = { image: ImageFunction };
52+
53+
type DataCollectionConfig<S extends BaseSchema> = {
54+
type: 'data';
55+
schema?: S | ((context: SchemaContext) => S);
56+
};
57+
58+
type ContentCollectionConfig<S extends BaseSchema> = {
59+
type?: 'content';
60+
schema?: S | ((context: SchemaContext) => S);
61+
};
62+
63+
type CollectionConfig<S> = ContentCollectionConfig<S> | DataCollectionConfig<S>;
64+
65+
export function defineCollection<S extends BaseSchema>(
66+
input: CollectionConfig<S>
67+
): CollectionConfig<S>;
68+
69+
type AllValuesOf<T> = T extends any ? T[keyof T] : never;
70+
type ValidContentEntrySlug<C extends keyof ContentEntryMap> = AllValuesOf<
71+
ContentEntryMap[C]
72+
>['slug'];
73+
74+
export function getEntryBySlug<
75+
C extends keyof ContentEntryMap,
76+
E extends ValidContentEntrySlug<C> | (string & {}),
77+
>(
78+
collection: C,
79+
// Note that this has to accept a regular string too, for SSR
80+
entrySlug: E
81+
): E extends ValidContentEntrySlug<C>
82+
? Promise<CollectionEntry<C>>
83+
: Promise<CollectionEntry<C> | undefined>;
84+
85+
export function getDataEntryById<C extends keyof DataEntryMap, E extends keyof DataEntryMap[C]>(
86+
collection: C,
87+
entryId: E
88+
): Promise<CollectionEntry<C>>;
89+
90+
export function getCollection<C extends keyof AnyEntryMap, E extends CollectionEntry<C>>(
91+
collection: C,
92+
filter?: (entry: CollectionEntry<C>) => entry is E
93+
): Promise<E[]>;
94+
export function getCollection<C extends keyof AnyEntryMap>(
95+
collection: C,
96+
filter?: (entry: CollectionEntry<C>) => unknown
97+
): Promise<CollectionEntry<C>[]>;
98+
99+
export function getEntry<
100+
C extends keyof ContentEntryMap,
101+
E extends ValidContentEntrySlug<C> | (string & {}),
102+
>(entry: {
103+
collection: C;
104+
slug: E;
105+
}): E extends ValidContentEntrySlug<C>
106+
? Promise<CollectionEntry<C>>
107+
: Promise<CollectionEntry<C> | undefined>;
108+
export function getEntry<
109+
C extends keyof DataEntryMap,
110+
E extends keyof DataEntryMap[C] | (string & {}),
111+
>(entry: {
112+
collection: C;
113+
id: E;
114+
}): E extends keyof DataEntryMap[C]
115+
? Promise<DataEntryMap[C][E]>
116+
: Promise<CollectionEntry<C> | undefined>;
117+
export function getEntry<
118+
C extends keyof ContentEntryMap,
119+
E extends ValidContentEntrySlug<C> | (string & {}),
120+
>(
121+
collection: C,
122+
slug: E
123+
): E extends ValidContentEntrySlug<C>
124+
? Promise<CollectionEntry<C>>
125+
: Promise<CollectionEntry<C> | undefined>;
126+
export function getEntry<
127+
C extends keyof DataEntryMap,
128+
E extends keyof DataEntryMap[C] | (string & {}),
129+
>(
130+
collection: C,
131+
id: E
132+
): E extends keyof DataEntryMap[C]
133+
? Promise<DataEntryMap[C][E]>
134+
: Promise<CollectionEntry<C> | undefined>;
135+
136+
/** Resolve an array of entry references from the same collection */
137+
export function getEntries<C extends keyof ContentEntryMap>(
138+
entries: {
139+
collection: C;
140+
slug: ValidContentEntrySlug<C>;
141+
}[]
142+
): Promise<CollectionEntry<C>[]>;
143+
export function getEntries<C extends keyof DataEntryMap>(
144+
entries: {
145+
collection: C;
146+
id: keyof DataEntryMap[C];
147+
}[]
148+
): Promise<CollectionEntry<C>[]>;
149+
150+
export function reference<C extends keyof AnyEntryMap>(
151+
collection: C
152+
): import('astro/zod').ZodEffects<
153+
import('astro/zod').ZodString,
154+
C extends keyof ContentEntryMap
155+
? {
156+
collection: C;
157+
slug: ValidContentEntrySlug<C>;
158+
}
159+
: {
160+
collection: C;
161+
id: keyof DataEntryMap[C];
162+
}
163+
>;
164+
// Allow generic `string` to avoid excessive type errors in the config
165+
// if `dev` is not running to update as you edit.
166+
// Invalid collection names will be caught at build time.
167+
export function reference<C extends string>(
168+
collection: C
169+
): import('astro/zod').ZodEffects<import('astro/zod').ZodString, never>;
170+
171+
type ReturnTypeOrOriginal<T> = T extends (...args: any[]) => infer R ? R : T;
172+
type InferEntrySchema<C extends keyof AnyEntryMap> = import('astro/zod').infer<
173+
ReturnTypeOrOriginal<Required<ContentConfig['collections'][C]>['schema']>
174+
>;
175+
176+
type ContentEntryMap = {
177+
"docs": {
178+
"about.md": {
179+
id: "about.md";
180+
slug: "about";
181+
body: string;
182+
collection: "docs";
183+
data: InferEntrySchema<"docs">
184+
} & { render(): Render[".md"] };
185+
"advanced.md": {
186+
id: "advanced.md";
187+
slug: "advanced";
188+
body: string;
189+
collection: "docs";
190+
data: InferEntrySchema<"docs">
191+
} & { render(): Render[".md"] };
192+
"cli.md": {
193+
id: "cli.md";
194+
slug: "cli";
195+
body: string;
196+
collection: "docs";
197+
data: InferEntrySchema<"docs">
198+
} & { render(): Render[".md"] };
199+
"introduction.md": {
200+
id: "introduction.md";
201+
slug: "introduction";
202+
body: string;
203+
collection: "docs";
204+
data: InferEntrySchema<"docs">
205+
} & { render(): Render[".md"] };
206+
"migration-guide.md": {
207+
id: "migration-guide.md";
208+
slug: "migration-guide";
209+
body: string;
210+
collection: "docs";
211+
data: InferEntrySchema<"docs">
212+
} & { render(): Render[".md"] };
213+
"node.md": {
214+
id: "node.md";
215+
slug: "node";
216+
body: string;
217+
collection: "docs";
218+
data: InferEntrySchema<"docs">
219+
} & { render(): Render[".md"] };
220+
"openapi-fetch/about.md": {
221+
id: "openapi-fetch/about.md";
222+
slug: "openapi-fetch/about";
223+
body: string;
224+
collection: "docs";
225+
data: InferEntrySchema<"docs">
226+
} & { render(): Render[".md"] };
227+
"openapi-fetch/api.md": {
228+
id: "openapi-fetch/api.md";
229+
slug: "openapi-fetch/api";
230+
body: string;
231+
collection: "docs";
232+
data: InferEntrySchema<"docs">
233+
} & { render(): Render[".md"] };
234+
"openapi-fetch/examples.md": {
235+
id: "openapi-fetch/examples.md";
236+
slug: "openapi-fetch/examples";
237+
body: string;
238+
collection: "docs";
239+
data: InferEntrySchema<"docs">
240+
} & { render(): Render[".md"] };
241+
"openapi-fetch/index.md": {
242+
id: "openapi-fetch/index.md";
243+
slug: "openapi-fetch";
244+
body: string;
245+
collection: "docs";
246+
data: InferEntrySchema<"docs">
247+
} & { render(): Render[".md"] };
248+
"v6/about.md": {
249+
id: "v6/about.md";
250+
slug: "v6/about";
251+
body: string;
252+
collection: "docs";
253+
data: InferEntrySchema<"docs">
254+
} & { render(): Render[".md"] };
255+
"v6/advanced.md": {
256+
id: "v6/advanced.md";
257+
slug: "v6/advanced";
258+
body: string;
259+
collection: "docs";
260+
data: InferEntrySchema<"docs">
261+
} & { render(): Render[".md"] };
262+
"v6/cli.md": {
263+
id: "v6/cli.md";
264+
slug: "v6/cli";
265+
body: string;
266+
collection: "docs";
267+
data: InferEntrySchema<"docs">
268+
} & { render(): Render[".md"] };
269+
"v6/introduction.md": {
270+
id: "v6/introduction.md";
271+
slug: "v6/introduction";
272+
body: string;
273+
collection: "docs";
274+
data: InferEntrySchema<"docs">
275+
} & { render(): Render[".md"] };
276+
"v6/node.md": {
277+
id: "v6/node.md";
278+
slug: "v6/node";
279+
body: string;
280+
collection: "docs";
281+
data: InferEntrySchema<"docs">
282+
} & { render(): Render[".md"] };
283+
};
284+
285+
};
286+
287+
type DataEntryMap = {
288+
289+
};
290+
291+
type AnyEntryMap = ContentEntryMap & DataEntryMap;
292+
293+
type ContentConfig = typeof import("../src/content/config");
294+
}

docs/.vitepress/config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export default defineConfig({
66
title: "OpenAPI TS",
77
description: "Consume OpenAPI 3.0 & 3.1 schemas in TypeScript",
88
cleanUrls: true,
9+
srcExclude: ["**/*/CONTRIBUTRING.md", "**/*/README.md"],
10+
ignoreDeadLinks: [/CODE_OF_CONDUCT/],
911
/** @see https://vitepress.dev/reference/default-theme-config */
1012
themeConfig: {
1113
siteTitle: false,

docs/6.x/advanced.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Advanced usage and various topics.
1111

1212
Fetching data can be done simply and safely using an **automatically-typed fetch wrapper**:
1313

14-
- [openapi-fetch](./openapi-fetch) (recommended)
14+
- [openapi-fetch](/openapi-fetch/) (recommended)
1515
- [openapi-typescript-fetch](https://www.npmjs.com/package/openapi-typescript-fetch) by [@ajaishankar](https://github.com/ajaishankar)
1616

1717
::: tip
@@ -78,7 +78,7 @@ describe("My API test", () => {
7878

7979
:::
8080

81-
_Note: this example uses a vanilla `fetch()` function, but any fetch wrapper—including [openapi-fetch](/openapi-fetch)—could be dropped in instead without any changes._
81+
_Note: this example uses a vanilla `fetch()` function, but any fetch wrapper—including [openapi-fetch](/openapi-fetch/)—could be dropped in instead without any changes._
8282

8383
And the magic that produces this would live in a `test/utils.ts` file that can be copy + pasted where desired (hidden for simplicity):
8484

docs/6.x/introduction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ type ErrorResponse =
7676

7777
From here, you can use these types for any of the following (but not limited to):
7878

79-
- Using an OpenAPI-supported fetch client (like [openapi-fetch](/openapi-fetch))
79+
- Using an OpenAPI-supported fetch client (like [openapi-fetch](/openapi-fetch/))
8080
- Asserting types for other API requestBodies and responses
8181
- Building core business logic based on API types
8282
- Validating mock test data is up-to-date with the current schema

docs/README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# openapi-typescript Docs
22

3-
Docs site powered by [Astro](https://github.com/withastro/astro), a modern static site generator.
3+
Docs site powered by [Vitepress](https://vitepress.dev/), an ergonomic docs site template powered by Vite.
44

55
Lives at [https://openapi-ts.pages.dev](https://openapi-ts.pages.dev).
66

@@ -13,13 +13,11 @@ pnpm 1
1313
pnpm run dev
1414
```
1515

16-
That will launch the docs site at `http://localhost:3000`.
16+
That will launch the docs site at `http://localhost:5173`.
1717

1818
## Editing
1919

20-
All content lives in the [content/](./src/content) directory, in `.md` files that should be familiar to edit to most.
21-
22-
For the non-markdown bits, please see the [Astro Documentation](https://docs.astro.build/en/getting-started/).
20+
All content lives in `.md` files that feature normal Markdown content [with powerful Vitepress extensions](https://vitepress.dev/guide/markdown).
2321

2422
## Contributing
2523

docs/advanced.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Advanced usage and various topics.
1111

1212
Fetching data can be done simply and safely using an **automatically-typed fetch wrapper**:
1313

14-
- [openapi-fetch](./openapi-fetch) (recommended)
14+
- [openapi-fetch](/openapi-fetch/) (recommended)
1515
- [openapi-typescript-fetch](https://www.npmjs.com/package/openapi-typescript-fetch) by [@ajaishankar](https://github.com/ajaishankar)
1616

1717
::: tip
@@ -89,7 +89,7 @@ describe("My API test", () => {
8989

9090
:::
9191

92-
_Note: this example uses a vanilla `fetch()` function, but any fetch wrapper—including [openapi-fetch](/openapi-fetch)—could be dropped in instead without any changes._
92+
_Note: this example uses a vanilla `fetch()` function, but any fetch wrapper—including [openapi-fetch](/openapi-fetch/)—could be dropped in instead without any changes._
9393

9494
And the magic that produces this would live in a `test/utils.ts` file that can be copy + pasted where desired (hidden for simplicity):
9595

docs/introduction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type ErrorResponse =
7070

7171
From here, you can use these types for any of the following (but not limited to):
7272

73-
- Using an OpenAPI-supported fetch client (like [openapi-fetch](/openapi-fetch))
73+
- Using an OpenAPI-supported fetch client (like [openapi-fetch](/openapi-fetch/))
7474
- Asserting types for other API requestBodies and responses
7575
- Building core business logic based on API types
7676
- Validating mock test data is up-to-date with the current schema

0 commit comments

Comments
 (0)