|
1 | 1 | <div align="center"> |
| 2 | + <img alt="Hey API presents openapi-ts" height="214" src="https://heyapi.dev/assets/.gen/openapi-ts-hero-640w.png" width="438"> |
2 | 3 | <h1><b>Spec Types</b></h1> |
| 4 | + <p>TypeScript definitions for OpenAPI and JSON Schema specifications with complete inline documentation.</p> |
3 | 5 | </div> |
4 | 6 |
|
5 | 7 | <p align="center"> |
6 | | - <!-- <a href="https://www.devtrends.dev/trends?c=v1.kZIBIg"><img src="https://api.devtrends.dev/badge/npm/%40hey-api%2Fopenapi-ts?period=month&style=flat&view=value" alt="DevTrends badge for @hey-api/openapi-ts" /></a> --> |
7 | | - <!-- <a href="https://www.devtrends.dev/trends?c=v1.kZIBIg&v=change"><img src="https://api.devtrends.dev/badge/npm/%40hey-api%2Fopenapi-ts?period=year&style=flat&view=change" alt="DevTrends badge for @hey-api/openapi-ts" /></a> --> |
| 8 | + <a href="https://www.devtrends.dev/trends?c=v1.kZIBzQM2"><img src="https://api.devtrends.dev/badge/npm/%40hey-api%2Fspec-types?period=month&style=flat&view=value" alt="DevTrends badge for @hey-api/spec-types" /></a> |
| 9 | + <a href="https://www.devtrends.dev/trends?c=v1.kZIBzQM2&v=change"><img src="https://api.devtrends.dev/badge/npm/%40hey-api%2Fspec-types?period=year&style=flat&view=change" alt="DevTrends badge for @hey-api/spec-types" /></a> |
8 | 10 | <a href="https://github.com/hey-api/openapi-ts/actions?query=branch%3Amain"><img src="https://github.com/hey-api/openapi-ts/actions/workflows/ci.yml/badge.svg?event=push&branch=main" alt="CI status" /></a> |
9 | 11 | <a href="https://github.com/hey-api/openapi-ts"><img src="https://img.shields.io/github/stars/hey-api/openapi-ts?style=flat&logo=github&label=GitHub&color=54C82D" alt="GitHub stars" /></a> |
10 | 12 | <a href="https://github.com/hey-api/openapi-ts/blob/main/LICENSE.md"><img src="https://img.shields.io/github/license/hey-api/openapi-ts" alt="MIT License"></a> |
11 | 13 | </p> |
12 | 14 |
|
13 | 15 | <p align="center"> |
14 | | - <!-- <a href="https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fsdk.gen.ts,src%2Fclient%2Ftypes.gen.ts">Demo</a> |
15 | | - <span> • </span> --> |
16 | | - <!-- <a href="https://heyapi.dev">Manual</a> |
17 | | - <span> • </span> --> |
| 16 | + <a href="https://heyapi.dev">Manual</a> |
| 17 | + <span> • </span> |
18 | 18 | <a href="https://github.com/hey-api/openapi-ts/issues">Issues</a> |
19 | 19 | <span> • </span> |
20 | 20 | <a href="https://heyapi.dev/openapi-ts/community/contributing">Contribute</a> |
|
25 | 25 | TypeScript definitions for OpenAPI and JSON Schema specifications with complete inline documentation. |
26 | 26 |
|
27 | 27 | Part of the Hey API ecosystem. |
| 28 | + |
| 29 | +## Features |
| 30 | + |
| 31 | +- OpenAPI 2.0 (Swagger), 3.0, and 3.1 specifications |
| 32 | +- JSON Schema Draft 4 and Draft 2020-12 |
| 33 | +- inline JSDoc on every property |
| 34 | +- zero runtime footprint, types only |
| 35 | + |
| 36 | +## Contributing |
| 37 | + |
| 38 | +Want to see your code in products used by millions? |
| 39 | + |
| 40 | +Start with our [Contributing](https://heyapi.dev/openapi-ts/community/contributing) guide and release your first feature. |
| 41 | + |
| 42 | +## Sponsors |
| 43 | + |
| 44 | +Hey API is sponsor-funded. If you rely on Hey API in production, consider becoming a [sponsor](https://github.com/sponsors/hey-api) to accelerate the roadmap. |
| 45 | + |
| 46 | +<h3 align="center">Gold</h3> |
| 47 | + |
| 48 | +<table align="center" style="justify-content: center;align-items: center;display: flex;"> |
| 49 | + <tbody> |
| 50 | + <tr> |
| 51 | + <td align="center" width="336px"> |
| 52 | + <p></p> |
| 53 | + <p> |
| 54 | + <a href="https://kutt.to/pkEZyc" target="_blank"> |
| 55 | + <picture height="50px"> |
| 56 | + <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/.gen/stainless-logo-wordmark-480w.jpeg"> |
| 57 | + <img alt="Stainless logo" height="50px" src="https://heyapi.dev/assets/.gen/stainless-logo-wordmark-480w.jpeg"> |
| 58 | + </picture> |
| 59 | + </a> |
| 60 | + <br/> |
| 61 | + Best-in-class developer interfaces for your API. |
| 62 | + <br/> |
| 63 | + <a href="https://kutt.to/pkEZyc" style="text-decoration:none;" target="_blank"> |
| 64 | + stainless.com |
| 65 | + </a> |
| 66 | + </p> |
| 67 | + <p></p> |
| 68 | + </td> |
| 69 | + <td align="center" width="336px"> |
| 70 | + <p></p> |
| 71 | + <p> |
| 72 | + <a href="https://kutt.to/QM9Q2N" target="_blank"> |
| 73 | + <picture height="50px"> |
| 74 | + <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/opencode/logo-light.svg"> |
| 75 | + <img alt="Opencode logo" height="50px" src="https://heyapi.dev/assets/opencode/logo-dark.svg"> |
| 76 | + </picture> |
| 77 | + </a> |
| 78 | + <br/> |
| 79 | + The open source coding agent. |
| 80 | + <br/> |
| 81 | + <a href="https://kutt.to/QM9Q2N" style="text-decoration:none;" target="_blank"> |
| 82 | + opencode.ai |
| 83 | + </a> |
| 84 | + </p> |
| 85 | + <p></p> |
| 86 | + </td> |
| 87 | + </tr> |
| 88 | + </tbody> |
| 89 | +</table> |
| 90 | + |
| 91 | +<h3 align="center">Silver</h3> |
| 92 | + |
| 93 | +<table align="center" style="justify-content: center;align-items: center;display: flex;"> |
| 94 | + <tbody> |
| 95 | + <tr> |
| 96 | + <td align="center" width="172px"> |
| 97 | + <a href="https://kutt.to/skQUVd" target="_blank"> |
| 98 | + <picture height="40px"> |
| 99 | + <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/scalar/logo-light.svg"> |
| 100 | + <img alt="Scalar logo" height="40px" src="https://heyapi.dev/assets/scalar/logo-dark.svg"> |
| 101 | + </picture> |
| 102 | + </a> |
| 103 | + <br/> |
| 104 | + <a href="https://kutt.to/skQUVd" style="text-decoration:none;" target="_blank"> |
| 105 | + scalar.com |
| 106 | + </a> |
| 107 | + </td> |
| 108 | + <td align="center" width="172px"> |
| 109 | + <a href="https://kutt.to/Dr9GuW" target="_blank"> |
| 110 | + <picture height="40px"> |
| 111 | + <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/fastapi/logo-light.svg"> |
| 112 | + <img alt="FastAPI logo" height="40px" src="https://heyapi.dev/assets/fastapi/logo-dark.svg"> |
| 113 | + </picture> |
| 114 | + </a> |
| 115 | + <br/> |
| 116 | + <a href="https://kutt.to/Dr9GuW" style="text-decoration:none;" target="_blank"> |
| 117 | + fastapi.tiangolo.com |
| 118 | + </a> |
| 119 | + </td> |
| 120 | + </tr> |
| 121 | + </tbody> |
| 122 | +</table> |
| 123 | + |
| 124 | +<h3 align="center">Bronze</h3> |
| 125 | + |
| 126 | +<table align="center" style="justify-content: center;align-items: center;display: flex;"> |
| 127 | + <tbody> |
| 128 | + <tr> |
| 129 | + <td align="center" width="136px"> |
| 130 | + <a href="https://kutt.to/YpaKsX" target="_blank"> |
| 131 | + <picture height="34px"> |
| 132 | + <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/.gen/kinde-logo-wordmark-dark-480w.webp"> |
| 133 | + <img alt="Kinde logo" height="34px" src="https://heyapi.dev/assets/.gen/kinde-logo-wordmark-480w.jpeg"> |
| 134 | + </picture> |
| 135 | + </a> |
| 136 | + </td> |
| 137 | + <td align="center" width="136px"> |
| 138 | + <a href="https://kutt.to/KkqSaw" target="_blank"> |
| 139 | + <picture height="34px"> |
| 140 | + <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/cella/logo-light.svg"> |
| 141 | + <img alt="Cella logo" height="34px" src="https://heyapi.dev/assets/cella/logo-dark.svg"> |
| 142 | + </picture> |
| 143 | + </a> |
| 144 | + </td> |
| 145 | + </tr> |
| 146 | + </tbody> |
| 147 | +</table> |
| 148 | + |
| 149 | +## Installation |
| 150 | + |
| 151 | +You can download `@hey-api/spec-types` from npm using your favorite package manager. |
| 152 | + |
| 153 | +#### npm |
| 154 | + |
| 155 | +```sh |
| 156 | +npm add @hey-api/spec-types -D -E |
| 157 | +``` |
| 158 | + |
| 159 | +#### pnpm |
| 160 | + |
| 161 | +```sh |
| 162 | +pnpm add @hey-api/spec-types -D -E |
| 163 | +``` |
| 164 | + |
| 165 | +#### yarn |
| 166 | + |
| 167 | +```sh |
| 168 | +yarn add @hey-api/spec-types -D -E |
| 169 | +``` |
| 170 | + |
| 171 | +#### bun |
| 172 | + |
| 173 | +```sh |
| 174 | +bun add @hey-api/spec-types -D -E |
| 175 | +``` |
| 176 | + |
| 177 | +## Usage |
| 178 | + |
| 179 | +### OpenAPI |
| 180 | + |
| 181 | +Hover over any property to see its definition from the specification. |
| 182 | + |
| 183 | +```ts |
| 184 | +import type { OpenAPIV3_1 } from '@hey-api/spec-types'; |
| 185 | + |
| 186 | +const doc = { |
| 187 | + openapi: '3.1.2', |
| 188 | + info: { |
| 189 | + title: 'My OpenAPI document', |
| 190 | + version: '1.0.0', |
| 191 | + }, |
| 192 | +} satisfies OpenAPIV3_1.Document; |
| 193 | +``` |
| 194 | + |
| 195 | +### JSON Schema |
| 196 | + |
| 197 | +Full type coverage for Draft 4 and Draft 2020-12 schemas. |
| 198 | + |
| 199 | +```ts |
| 200 | +import type { JSONSchemaDraft2020_12 } from '@hey-api/spec-types'; |
| 201 | + |
| 202 | +const doc = { |
| 203 | + properties: { |
| 204 | + foo: { |
| 205 | + type: 'string', |
| 206 | + }, |
| 207 | + }, |
| 208 | + type: 'object', |
| 209 | +} satisfies JSONSchemaDraft2020_12.Document; |
| 210 | +``` |
| 211 | + |
| 212 | +## License |
| 213 | + |
| 214 | +Released under the [MIT License](https://github.com/hey-api/openapi-ts/blob/main/LICENSE.md). |
0 commit comments