fork of hey-api/openapi-ts because I need some additional things

Merge pull request #476 from hey-api/docs/examples

docs: add examples

authored by

Lubos and committed by
GitHub
d4b6dbb5 ab776958

+129 -30
+5
.changeset/ninety-hairs-own.md
··· 1 + --- 2 + "@hey-api/docs": patch 3 + --- 4 + 5 + docs: add examples
+21 -7
README.md
··· 1 1 <div align="center"> 2 - <img width="150" height="150" src="https://heyapi.vercel.app/logo.png" alt="Logo"> 3 - <h1 align="center"><b>OpenAPI Typescript</b></h1> 4 - <p align="center">✨ Turn your OpenAPI specification into a beautiful TypeScript client.</p> 2 + <img width="150" height="150" src="https://heyapi.vercel.app/logo.png" alt="Logo"> 3 + <h1 align="center"><b>OpenAPI Typescript</b></h1> 4 + <p align="center">✨ Turn your OpenAPI specification into a beautiful TypeScript client.</p> 5 5 </div> 6 6 7 - ## GitHub Integration (coming soon) 7 + Generate TypeScript interfaces, REST clients, and JSON Schemas from OpenAPI specifications. 8 8 9 - Automatically update your code when the APIs it depends on change. [Find out more](https://heyapi.vercel.app/openapi-ts/integrations.html). 9 + [Live demo](https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fservices.gen.ts,src%2Fclient%2Ftypes.gen.ts) 10 10 11 - ## Migrating from OpenAPI Typescript Codegen? 11 + ## Features 12 12 13 - Please read our [migration guide](https://heyapi.vercel.app/openapi-ts/migrating.html#openapi-typescript-codegen). 13 + - works with CLI, Node.js, or npx 14 + - supports OpenAPI 2.0, 3.0, and 3.1 specifications 15 + - supports both JSON and YAML input files 16 + - supports external references using [json-schema-ref-parser](https://github.com/APIDevTools/json-schema-ref-parser/) 17 + - generates TypeScript interfaces, REST clients, and JSON Schemas 18 + - Fetch API, Axios, Angular, Node.js, and XHR clients available 19 + - abortable requests through cancellable promise pattern 14 20 15 21 ## Documentation 16 22 17 23 Please visit our [website](https://heyapi.vercel.app/) for documentation, guides, migrating, and more. 24 + 25 + ## GitHub Integration (coming soon) 26 + 27 + Automatically update your code when the APIs it depends on change. [Find out more](https://heyapi.vercel.app/openapi-ts/integrations.html). 28 + 29 + ## Migrating from OpenAPI Typescript Codegen? 30 + 31 + Please read our [migration guide](https://heyapi.vercel.app/openapi-ts/migrating.html#openapi-typescript-codegen). 18 32 19 33 ## Contributing 20 34
+5 -2
docs/.vitepress/config/shared.ts
··· 21 21 {}, 22 22 'window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };', 23 23 ], 24 - ['script', { defer: '', src: '/_vercel/insights/script.js' }], 25 - ], 24 + process.env.NODE_ENV === 'production' && [ 25 + 'script', 26 + { defer: '', src: '/_vercel/insights/script.js' }, 27 + ], 28 + ].filter(Boolean), 26 29 lastUpdated: false, 27 30 sitemap: { 28 31 hostname: 'https://heyapi.vercel.app',
+21
docs/.vitepress/theme/custom.css
··· 25 25 text-transform: lowercase; 26 26 top: -1em; 27 27 } 28 + 29 + iframe { 30 + background-color: var(--vp-sidebar-bg-color); 31 + border: none; 32 + margin: 0; 33 + } 34 + 35 + .buttonLink { 36 + color: var(--vp-c-brand-1); 37 + font-size: 16px; 38 + font-weight: 500; 39 + text-decoration: underline; 40 + text-underline-offset: 2px; 41 + transition: 42 + color 0.25s, 43 + opacity 0.25s; 44 + } 45 + 46 + .buttonLink:hover { 47 + color: var(--vp-c-brand-2); 48 + }
+19
docs/embed.ts
··· 1 + import sdk from '@stackblitz/sdk'; 2 + 3 + export const embedProject = (projectId: string) => async (event: Event) => { 4 + const container = document.createElement('div'); 5 + 6 + if (event.target) { 7 + const node = event.target as HTMLElement; 8 + node.replaceWith(container); 9 + } 10 + 11 + if (projectId === 'hey-api-example') { 12 + return await sdk.embedProjectId(container, projectId, { 13 + height: 700, 14 + openFile: 15 + 'openapi-ts.config.ts,src/client/schemas.gen.ts,src/client/services.gen.ts,src/client/types.gen.ts', 16 + view: 'editor', 17 + }); 18 + } 19 + };
+3 -3
docs/index.md
··· 9 9 text: Get Started 10 10 link: /openapi-ts/get-started 11 11 - theme: alt 12 - text: View on GitHub 13 - link: https://github.com/hey-api/openapi-ts 12 + text: View Demo 13 + link: https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fservices.gen.ts,src%2Fclient%2Ftypes.gen.ts 14 14 image: 15 15 src: /logo.png 16 16 alt: logo ··· 38 38 39 39 ### Migrating from OpenAPI Typescript Codegen? 40 40 41 - Please read our [migration guide](/openapi-ts/migrating#openapi-typescript-codegen). 41 + Read our [migration guide](/openapi-ts/migrating#openapi-typescript-codegen). 42 42 43 43 <style> 44 44 :root {
+4
docs/openapi-ts/clients.md
··· 8 8 We all send HTTP requests in a slightly different way. Hey API doesn't force you to use any specific technology. What we do, however, is support your choice with great clients. All seamlessly integrated with our other features. 9 9 10 10 [Next.js](https://nextjs.org/), [Axios](https://axios-http.com/), and [Fetch API](https://developer.mozilla.org/docs/Web/API/Fetch_API) coming soon. 11 + 12 + ## Examples 13 + 14 + You can view live examples on [StackBlitz](https://stackblitz.com/orgs/github/hey-api/collections/openapi-ts-examples).
+4
docs/openapi-ts/configuration.md
··· 239 239 ## Config API 240 240 241 241 You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/types/config.ts) interface. 242 + 243 + ## Examples 244 + 245 + You can view live examples on [StackBlitz](https://stackblitz.com/orgs/github/hey-api/collections/openapi-ts-examples).
+19 -7
docs/openapi-ts/get-started.md
··· 3 3 description: Get started with @hey-api/openapi-ts. 4 4 --- 5 5 6 + <script setup> 7 + import { embedProject } from '../embed' 8 + </script> 9 + 6 10 # Get Started 7 11 8 - `openapi-ts` allows you to create TypeScript interfaces, REST clients, and JSON Schemas from an OpenAPI specification. 12 + Generate TypeScript interfaces, REST clients, and JSON Schemas from OpenAPI specifications. 13 + 14 + <button class="buttonLink" @click="(event) => embedProject('hey-api-example')(event)"> 15 + Live demo 16 + </button> 9 17 10 18 ## Features 11 19 12 - - use with CLI, Node.js, or npx 13 - - export TypeScript interfaces from OpenAPI v2.0, v3.0, and v3.1 specifications 14 - - support JSON or YAML input files 15 - - support external references using [json-schema-ref-parser](https://github.com/APIDevTools/json-schema-ref-parser/) 16 - - create fetch, axios, angular, node.js, or xhr REST clients 17 - - export JSON Schemas from OpenAPI specifications 20 + - works with CLI, Node.js, or npx 21 + - supports OpenAPI 2.0, 3.0, and 3.1 specifications 22 + - supports both JSON and YAML input files 23 + - supports external references using [json-schema-ref-parser](https://github.com/APIDevTools/json-schema-ref-parser/) 24 + - generates TypeScript interfaces, REST clients, and JSON Schemas 25 + - Fetch API, Axios, Angular, Node.js, and XHR clients available 18 26 - abortable requests through cancellable promise pattern 19 27 20 28 ## Quick Start ··· 71 79 ::: warning 72 80 You need to be running Node.js v18 or newer 73 81 ::: 82 + 83 + ## Examples 84 + 85 + You can view live examples on [StackBlitz](https://stackblitz.com/orgs/github/hey-api/collections/openapi-ts-examples).
+4
docs/openapi-ts/interceptors.md
··· 52 52 ::: warning 53 53 Angular client does not currently support request interceptors. 54 54 ::: 55 + 56 + ## Examples 57 + 58 + You can view live examples on [StackBlitz](https://stackblitz.com/orgs/github/hey-api/collections/openapi-ts-examples).
+3
docs/package.json
··· 9 9 "dev": "vitepress dev", 10 10 "preview": "vitepress preview" 11 11 }, 12 + "dependencies": { 13 + "@stackblitz/sdk": "1.9.0" 14 + }, 12 15 "devDependencies": { 13 16 "vitepress": "1.1.3" 14 17 }
+13 -11
packages/openapi-ts/README.md
··· 4 4 <p align="center">✨ Turn your OpenAPI specification into a beautiful TypeScript client.</p> 5 5 </div> 6 6 7 - `openapi-ts` allows you to create TypeScript interfaces, REST clients, and JSON Schemas from an OpenAPI specification. 7 + Generate TypeScript interfaces, REST clients, and JSON Schemas from OpenAPI specifications. 8 + 9 + [Live demo](https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fservices.gen.ts,src%2Fclient%2Ftypes.gen.ts) 8 10 9 11 ## Features 10 12 11 - - use with CLI, Node.js, or npx 12 - - export TypeScript interfaces from OpenAPI v2.0, v3.0, and v3.1 specifications 13 - - support JSON or YAML input files 14 - - support external references using [json-schema-ref-parser](https://github.com/APIDevTools/json-schema-ref-parser/) 15 - - create fetch, axios, angular, node.js, or xhr REST clients 16 - - export JSON Schemas from OpenAPI specifications 13 + - works with CLI, Node.js, or npx 14 + - supports OpenAPI 2.0, 3.0, and 3.1 specifications 15 + - supports both JSON and YAML input files 16 + - supports external references using [json-schema-ref-parser](https://github.com/APIDevTools/json-schema-ref-parser/) 17 + - generates TypeScript interfaces, REST clients, and JSON Schemas 18 + - Fetch API, Axios, Angular, Node.js, and XHR clients available 17 19 - abortable requests through cancellable promise pattern 18 20 21 + ## Documentation 22 + 23 + Please visit our [website](https://heyapi.vercel.app/) for documentation, guides, migrating, and more. 24 + 19 25 ## GitHub Integration (coming soon) 20 26 21 27 Automatically update your code when the APIs it depends on change. [Find out more](https://heyapi.vercel.app/openapi-ts/integrations.html). ··· 23 29 ## Migrating from OpenAPI Typescript Codegen? 24 30 25 31 Please read our [migration guide](https://heyapi.vercel.app/openapi-ts/migrating.html#openapi-typescript-codegen). 26 - 27 - ## Documentation 28 - 29 - Please visit our [website](https://heyapi.vercel.app/) for documentation, guides, migrating, and more. 30 32 31 33 ## Contributing 32 34
+8
pnpm-lock.yaml
··· 73 73 version: 1.5.0(@types/node@20.12.7) 74 74 75 75 docs: 76 + dependencies: 77 + '@stackblitz/sdk': 78 + specifier: 1.9.0 79 + version: 1.9.0 76 80 devDependencies: 77 81 vitepress: 78 82 specifier: 1.1.3 ··· 3462 3466 /@sinclair/typebox@0.27.8: 3463 3467 resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} 3464 3468 dev: true 3469 + 3470 + /@stackblitz/sdk@1.9.0: 3471 + resolution: {integrity: sha512-3m6C7f8pnR5KXys/Hqx2x6ylnpqOak6HtnZI6T5keEO0yT+E4Spkw37VEbdwuC+2oxmjdgq6YZEgiKX7hM1GmQ==} 3472 + dev: false 3465 3473 3466 3474 /@svitejs/changesets-changelog-github-compact@1.1.0: 3467 3475 resolution: {integrity: sha512-qhUGGDHcpbY2zpjW3SwqchuW8J/5EzlPFud7xNntHKA7f3a/mx5+g+ruJKFHSAiVZYo30PALt+AyhmPUNKH/Og==}