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

Merge pull request #2489 from hey-api/fix/api-registry-shorthand

feat(input): input supports Hey API Registry shorthand

authored by

Lubos and committed by
GitHub
2a0c7989 c74279c2

+658 -570
+5
.changeset/soft-penguins-fetch.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + feat(input): input supports Hey API Registry shorthand
+4 -4
docs/openapi-ts/clients/angular.md
··· 49 49 50 50 ```js [config] 51 51 export default { 52 - input: 'https://get.heyapi.dev/hey-api/backend', 52 + input: 'hey-api/backend', // sign up at app.heyapi.dev 53 53 output: 'src/client', 54 54 plugins: ['@hey-api/client-angular'], // [!code ++] 55 55 }; ··· 57 57 58 58 ```sh [cli] 59 59 npx @hey-api/openapi-ts \ 60 - -i https://get.heyapi.dev/hey-api/backend \ 60 + -i hey-api/backend \ 61 61 -o src/client \ 62 62 -c @hey-api/client-angular # [!code ++] 63 63 ``` ··· 105 105 106 106 ```js 107 107 export default { 108 - input: 'https://get.heyapi.dev/hey-api/backend', 108 + input: 'hey-api/backend', // sign up at app.heyapi.dev 109 109 output: 'src/client', 110 110 plugins: [ 111 111 { ··· 178 178 179 179 ```js [config] 180 180 export default { 181 - input: 'https://get.heyapi.dev/hey-api/backend', 181 + input: 'hey-api/backend', // sign up at app.heyapi.dev 182 182 output: 'src/client', 183 183 plugins: [ 184 184 '@hey-api/client-angular',
+4 -4
docs/openapi-ts/clients/angular/v19.md
··· 49 49 50 50 ```js [config] 51 51 export default { 52 - input: 'https://get.heyapi.dev/hey-api/backend', 52 + input: 'hey-api/backend', // sign up at app.heyapi.dev 53 53 output: 'src/client', 54 54 plugins: ['@hey-api/client-angular'], // [!code ++] 55 55 }; ··· 57 57 58 58 ```sh [cli] 59 59 npx @hey-api/openapi-ts \ 60 - -i https://get.heyapi.dev/hey-api/backend \ 60 + -i hey-api/backend \ 61 61 -o src/client \ 62 62 -c @hey-api/client-angular # [!code ++] 63 63 ``` ··· 105 105 106 106 ```js 107 107 export default { 108 - input: 'https://get.heyapi.dev/hey-api/backend', 108 + input: 'hey-api/backend', // sign up at app.heyapi.dev 109 109 output: 'src/client', 110 110 plugins: [ 111 111 { ··· 178 178 179 179 ```js [config] 180 180 export default { 181 - input: 'https://get.heyapi.dev/hey-api/backend', 181 + input: 'hey-api/backend', // sign up at app.heyapi.dev 182 182 output: 'src/client', 183 183 plugins: [ 184 184 '@hey-api/client-angular',
+3 -3
docs/openapi-ts/clients/axios.md
··· 46 46 47 47 ```js [config] 48 48 export default { 49 - input: 'https://get.heyapi.dev/hey-api/backend', 49 + input: 'hey-api/backend', // sign up at app.heyapi.dev 50 50 output: 'src/client', 51 51 plugins: ['@hey-api/client-axios'], // [!code ++] 52 52 }; ··· 54 54 55 55 ```sh [cli] 56 56 npx @hey-api/openapi-ts \ 57 - -i https://get.heyapi.dev/hey-api/backend \ 57 + -i hey-api/backend \ 58 58 -o src/client \ 59 59 -c @hey-api/client-axios # [!code ++] 60 60 ``` ··· 87 87 88 88 ```js 89 89 export default { 90 - input: 'https://get.heyapi.dev/hey-api/backend', 90 + input: 'hey-api/backend', // sign up at app.heyapi.dev 91 91 output: 'src/client', 92 92 plugins: [ 93 93 {
+3 -3
docs/openapi-ts/clients/fetch.md
··· 39 39 40 40 ```js [config] 41 41 export default { 42 - input: 'https://get.heyapi.dev/hey-api/backend', 42 + input: 'hey-api/backend', // sign up at app.heyapi.dev 43 43 output: 'src/client', 44 44 plugins: ['@hey-api/client-fetch'], // [!code ++] 45 45 }; ··· 47 47 48 48 ```sh [cli] 49 49 npx @hey-api/openapi-ts \ 50 - -i https://get.heyapi.dev/hey-api/backend \ 50 + -i hey-api/backend \ 51 51 -o src/client \ 52 52 -c @hey-api/client-fetch # [!code ++] 53 53 ``` ··· 86 86 87 87 ```js 88 88 export default { 89 - input: 'https://get.heyapi.dev/hey-api/backend', 89 + input: 'hey-api/backend', // sign up at app.heyapi.dev 90 90 output: 'src/client', 91 91 plugins: [ 92 92 {
+5 -5
docs/openapi-ts/clients/legacy.md
··· 19 19 20 20 ```js [fetch] 21 21 export default { 22 - input: 'https://get.heyapi.dev/hey-api/backend', 22 + input: 'hey-api/backend', // sign up at app.heyapi.dev 23 23 output: 'src/client', 24 24 plugins: ['legacy/fetch'], // [!code ++] 25 25 }; ··· 27 27 28 28 ```js [axios] 29 29 export default { 30 - input: 'https://get.heyapi.dev/hey-api/backend', 30 + input: 'hey-api/backend', // sign up at app.heyapi.dev 31 31 output: 'src/client', 32 32 plugins: ['legacy/axios'], // [!code ++] 33 33 }; ··· 35 35 36 36 ```js [angular] 37 37 export default { 38 - input: 'https://get.heyapi.dev/hey-api/backend', 38 + input: 'hey-api/backend', // sign up at app.heyapi.dev 39 39 output: 'src/client', 40 40 plugins: ['legacy/angular'], // [!code ++] 41 41 }; ··· 43 43 44 44 ```js [node] 45 45 export default { 46 - input: 'https://get.heyapi.dev/hey-api/backend', 46 + input: 'hey-api/backend', // sign up at app.heyapi.dev 47 47 output: 'src/client', 48 48 plugins: ['legacy/node'], // [!code ++] 49 49 }; ··· 51 51 52 52 ```js [xhr] 53 53 export default { 54 - input: 'https://get.heyapi.dev/hey-api/backend', 54 + input: 'hey-api/backend', // sign up at app.heyapi.dev 55 55 output: 'src/client', 56 56 plugins: ['legacy/xhr'], // [!code ++] 57 57 };
+3 -3
docs/openapi-ts/clients/next-js.md
··· 29 29 30 30 ```js [config] 31 31 export default { 32 - input: 'https://get.heyapi.dev/hey-api/backend', 32 + input: 'hey-api/backend', // sign up at app.heyapi.dev 33 33 output: 'src/client', 34 34 plugins: ['@hey-api/client-next'], // [!code ++] 35 35 }; ··· 37 37 38 38 ```sh [cli] 39 39 npx @hey-api/openapi-ts \ 40 - -i https://get.heyapi.dev/hey-api/backend \ 40 + -i hey-api/backend \ 41 41 -o src/client \ 42 42 -c @hey-api/client-next # [!code ++] 43 43 ``` ··· 56 56 57 57 ```js 58 58 export default { 59 - input: 'https://get.heyapi.dev/hey-api/backend', 59 + input: 'hey-api/backend', // sign up at app.heyapi.dev 60 60 output: 'src/client', 61 61 plugins: [ 62 62 {
+3 -3
docs/openapi-ts/clients/nuxt.md
··· 64 64 65 65 ```js [config] 66 66 export default { 67 - input: 'https://get.heyapi.dev/hey-api/backend', 67 + input: 'hey-api/backend', // sign up at app.heyapi.dev 68 68 output: 'src/client', 69 69 plugins: ['@hey-api/client-nuxt'], // [!code ++] 70 70 }; ··· 72 72 73 73 ```sh [cli] 74 74 npx @hey-api/openapi-ts \ 75 - -i https://get.heyapi.dev/hey-api/backend \ 75 + -i hey-api/backend \ 76 76 -o src/client \ 77 77 -c @hey-api/client-nuxt # [!code ++] 78 78 ``` ··· 111 111 112 112 ```js 113 113 export default { 114 - input: 'https://get.heyapi.dev/hey-api/backend', 114 + input: 'hey-api/backend', // sign up at app.heyapi.dev 115 115 output: 'src/client', 116 116 plugins: [ 117 117 {
+16 -8
docs/openapi-ts/configuration.md
··· 13 13 import { defineConfig } from '@hey-api/openapi-ts'; 14 14 15 15 export default defineConfig({ 16 - input: 'https://get.heyapi.dev/hey-api/backend', 16 + input: 'hey-api/backend', // sign up at app.heyapi.dev 17 17 output: 'src/client', 18 18 }); 19 19 ``` ··· 21 21 ```js [openapi-ts.config.cjs] 22 22 /** @type {import('@hey-api/openapi-ts').UserConfig} */ 23 23 module.exports = { 24 - input: 'https://get.heyapi.dev/hey-api/backend', 24 + input: 'hey-api/backend', // sign up at app.heyapi.dev 25 25 output: 'src/client', 26 26 }; 27 27 ``` ··· 29 29 ```js [openapi-ts.config.mjs] 30 30 /** @type {import('@hey-api/openapi-ts').UserConfig} */ 31 31 export default { 32 - input: 'https://get.heyapi.dev/hey-api/backend', 32 + input: 'hey-api/backend', // sign up at app.heyapi.dev 33 33 output: 'src/client', 34 34 }; 35 35 ``` ··· 65 65 66 66 ## Input 67 67 68 - You must set the input so we can load your OpenAPI specification. It can be a path or URL, object containing a path or URL, or an object representing an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats. 68 + You must provide an input so we can load your OpenAPI specification. 69 + 70 + The input can be a string path, URL, API registry shorthand, an object containing any of these, or an object representing an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats. 69 71 70 72 You can learn more on the [Input](/openapi-ts/configuration/input) page. 71 73 ··· 79 81 80 82 ```js [url] 81 83 export default { 82 - input: 'https://get.heyapi.dev/hey-api/backend', // [!code ++] 84 + input: 'https://get.heyapi.dev/hey-api/backend', // sign up at app.heyapi.dev // [!code ++] 85 + }; 86 + ``` 87 + 88 + ```js [registry] 89 + export default { 90 + input: 'hey-api/backend', // sign up at app.heyapi.dev // [!code ++] 83 91 }; 84 92 ``` 85 93 ··· 87 95 ```js [object] 88 96 export default { 89 97 input: { // [!code ++] 90 - path: 'https://get.heyapi.dev/hey-api/backend', // [!code ++] 98 + path: 'hey-api/backend', // sign up at app.heyapi.dev // [!code ++] 91 99 // ...other options // [!code ++] 92 100 }, // [!code ++] 93 101 }; ··· 120 128 121 129 ```js [path] 122 130 export default { 123 - input: 'https://get.heyapi.dev/hey-api/backend', 131 + input: 'hey-api/backend', // sign up at app.heyapi.dev 124 132 output: 'src/client', // [!code ++] 125 133 }; 126 134 ``` ··· 128 136 <!-- prettier-ignore-start --> 129 137 ```js [object] 130 138 export default { 131 - input: 'https://get.heyapi.dev/hey-api/backend', 139 + input: 'hey-api/backend', // sign up at app.heyapi.dev 132 140 output: { // [!code ++] 133 141 path: 'src/client', // [!code ++] 134 142 // ...other options // [!code ++]
+49 -47
docs/openapi-ts/configuration/input.md
··· 5 5 6 6 # Input 7 7 8 - You must set the input so we can load your OpenAPI specification. 8 + You must provide an input so we can load your OpenAPI specification. 9 9 10 10 ## Input 11 11 12 - Input can be a path or URL, object containing a path or URL, or an object representing an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats. 12 + The input can be a string path, URL, API registry shorthand, an object containing any of these, or an object representing an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats. 13 13 14 14 ::: code-group 15 15 ··· 21 21 22 22 ```js [url] 23 23 export default { 24 - input: 'https://get.heyapi.dev/hey-api/backend', // [!code ++] 24 + input: 'https://get.heyapi.dev/hey-api/backend', // sign up at app.heyapi.dev // [!code ++] 25 + }; 26 + ``` 27 + 28 + ```js [registry] 29 + export default { 30 + input: 'hey-api/backend', // sign up at app.heyapi.dev // [!code ++] 25 31 }; 26 32 ``` 27 33 ··· 29 35 ```js [object] 30 36 export default { 31 37 input: { // [!code ++] 32 - path: 'https://get.heyapi.dev/hey-api/backend', // [!code ++] 38 + path: 'hey-api/backend', // sign up at app.heyapi.dev // [!code ++] 33 39 // ...other options // [!code ++] 34 40 }, // [!code ++] 35 41 }; ··· 52 58 If you use an HTTPS URL with a self-signed certificate in development, you will need to set [`NODE_TLS_REJECT_UNAUTHORIZED=0`](https://github.com/hey-api/openapi-ts/issues/276#issuecomment-2043143501) in your environment. 53 59 ::: 54 60 55 - ### ReadMe API Registry 56 - 57 - You can use ReadMe API Registry UUIDs to fetch OpenAPI specifications directly from ReadMe's platform. This is useful when API providers use ReadMe as their source of truth for API documentation. 58 - 59 - ::: code-group 60 - 61 - ```js [simple format] 62 - export default { 63 - input: 'readme:abc123def456', // [!code ++] 64 - }; 65 - ``` 61 + ### Request options 66 62 67 - ```js [full format] 68 - export default { 69 - input: 'readme:@organization/project#abc123def456', // [!code ++] 70 - }; 71 - ``` 63 + You can pass any valid Fetch API [options](https://developer.mozilla.org/docs/Web/API/RequestInit) to the request for fetching your specification. This is useful if your file is behind auth for example. 72 64 73 - ```js [object format] 65 + <!-- prettier-ignore-start --> 66 + ```js 74 67 export default { 75 68 input: { 76 - path: 'readme:abc123def456', // [!code ++] 77 - // ...other options 69 + path: 'https://secret.com/protected-spec', 70 + fetch: { // [!code ++] 71 + headers: { // [!code ++] 72 + Authorization: 'Bearer xxx', // [!code ++] 73 + }, // [!code ++] 74 + }, // [!code ++] 78 75 }, 79 76 }; 80 77 ``` 78 + <!-- prettier-ignore-end --> 81 79 82 - ::: 80 + ## API Registry 83 81 84 - The ReadMe input formats are: 82 + You can store your specifications in an API registry to serve as a single source of truth. This helps prevent drift, improves discoverability, enables version tracking, and more. 85 83 86 - - `readme:uuid` - Simple format using only the UUID 87 - - `readme:@organization/project#uuid` - Full format including organization and project names 84 + ### Hey API 88 85 89 - Both formats will fetch the OpenAPI specification from `https://dash.readme.com/api/v1/api-registry/{uuid}`. 86 + You can learn more about [Hey API Platform](https://app.heyapi.dev) on the [Integrations](/openapi-ts/integrations) page. 90 87 91 - ### Hey API Platform options 88 + ```js [uuid] 89 + export default { 90 + input: 'hey-api/backend', // sign up at app.heyapi.dev // [!code ++] 91 + }; 92 + ``` 92 93 93 - You might want to use the [Hey API Platform](/openapi-ts/integrations) to store your specifications. If you do so, the `input` object provides options to help with constructing the correct URL. 94 + The `input` object lets you provide additional options to construct the correct URL. 94 95 95 96 ```js 96 97 export default { 97 98 input: { 98 - path: 'https://get.heyapi.dev/', 99 + path: 'hey-api/backend', // sign up at app.heyapi.dev 99 100 branch: 'main', // [!code ++] 100 - project: 'backend', // [!code ++] 101 101 }, 102 102 }; 103 103 ``` 104 104 105 - ### Request options 105 + We also provide shorthands for other registries: 106 106 107 - You can pass any valid Fetch API [options](https://developer.mozilla.org/docs/Web/API/RequestInit) to the request for fetching your specification. This is useful if your file is behind auth for example. 107 + ::: details ReadMe 108 + Prefix your input with `readme:` to use the ReadMe API Registry. 108 109 109 - <!-- prettier-ignore-start --> 110 - ```js 110 + ::: code-group 111 + 112 + ```js [uuid] 111 113 export default { 112 - input: { 113 - path: 'https://secret.com/protected-spec', 114 - fetch: { // [!code ++] 115 - headers: { // [!code ++] 116 - Authorization: 'Bearer xxx', // [!code ++] 117 - }, // [!code ++] 118 - }, // [!code ++] 119 - }, 114 + input: 'readme:nysezql0wwo236', // [!code ++] 120 115 }; 121 116 ``` 122 - <!-- prettier-ignore-end --> 117 + 118 + ```js [long] 119 + export default { 120 + input: 'readme:@developers/v2.0#nysezql0wwo236', // [!code ++] 121 + }; 122 + ``` 123 + 124 + ::: 123 125 124 126 ## Watch Mode 125 127 ··· 134 136 ```js [config] 135 137 export default { 136 138 input: { 137 - path: 'https://get.heyapi.dev/hey-api/backend', 139 + path: 'hey-api/backend', // sign up at app.heyapi.dev 138 140 watch: true, // [!code ++] 139 141 }, 140 142 }; ··· 142 144 143 145 ```sh [cli] 144 146 npx @hey-api/openapi-ts \ 145 - -i https://get.heyapi.dev/hey-api/backend \ 147 + -i hey-api/backend \ 146 148 -o src/client \ 147 149 -w # [!code ++] 148 150 ```
+12 -12
docs/openapi-ts/configuration/output.md
··· 15 15 16 16 ```js [path] 17 17 export default { 18 - input: 'https://get.heyapi.dev/hey-api/backend', 18 + input: 'hey-api/backend', // sign up at app.heyapi.dev 19 19 output: 'src/client', // [!code ++] 20 20 }; 21 21 ``` ··· 23 23 <!-- prettier-ignore-start --> 24 24 ```js [object] 25 25 export default { 26 - input: 'https://get.heyapi.dev/hey-api/backend', 26 + input: 'hey-api/backend', // sign up at app.heyapi.dev 27 27 output: { // [!code ++] 28 28 path: 'src/client', // [!code ++] 29 29 // ...other options // [!code ++] ··· 42 42 43 43 ```js [disabled] 44 44 export default { 45 - input: 'https://get.heyapi.dev/hey-api/backend', 45 + input: 'hey-api/backend', // sign up at app.heyapi.dev 46 46 output: { 47 47 format: false, // [!code ++] 48 48 path: 'src/client', ··· 52 52 53 53 ```js [prettier] 54 54 export default { 55 - input: 'https://get.heyapi.dev/hey-api/backend', 55 + input: 'hey-api/backend', // sign up at app.heyapi.dev 56 56 output: { 57 57 format: 'prettier', // [!code ++] 58 58 path: 'src/client', ··· 62 62 63 63 ```js [biome] 64 64 export default { 65 - input: 'https://get.heyapi.dev/hey-api/backend', 65 + input: 'hey-api/backend', // sign up at app.heyapi.dev 66 66 output: { 67 67 format: 'biome', // [!code ++] 68 68 path: 'src/client', ··· 82 82 83 83 ```js [disabled] 84 84 export default { 85 - input: 'https://get.heyapi.dev/hey-api/backend', 85 + input: 'hey-api/backend', // sign up at app.heyapi.dev 86 86 output: { 87 87 lint: false, // [!code ++] 88 88 path: 'src/client', ··· 92 92 93 93 ```js [eslint] 94 94 export default { 95 - input: 'https://get.heyapi.dev/hey-api/backend', 95 + input: 'hey-api/backend', // sign up at app.heyapi.dev 96 96 output: { 97 97 lint: 'eslint', // [!code ++] 98 98 path: 'src/client', ··· 102 102 103 103 ```js [biome] 104 104 export default { 105 - input: 'https://get.heyapi.dev/hey-api/backend', 105 + input: 'hey-api/backend', // sign up at app.heyapi.dev 106 106 output: { 107 107 lint: 'biome', // [!code ++] 108 108 path: 'src/client', ··· 112 112 113 113 ```js [oxlint] 114 114 export default { 115 - input: 'https://get.heyapi.dev/hey-api/backend', 115 + input: 'hey-api/backend', // sign up at app.heyapi.dev 116 116 output: { 117 117 lint: 'oxlint', // [!code ++] 118 118 path: 'src/client', ··· 132 132 133 133 ```js [custom] 134 134 export default { 135 - input: 'https://get.heyapi.dev/hey-api/backend', 135 + input: 'hey-api/backend', // sign up at app.heyapi.dev 136 136 output: { 137 137 path: 'src/client', 138 138 tsConfigPath: './config/tsconfig.custom.json', // [!code ++] ··· 142 142 143 143 ```js [off] 144 144 export default { 145 - input: 'https://get.heyapi.dev/hey-api/backend', 145 + input: 'hey-api/backend', // sign up at app.heyapi.dev 146 146 output: { 147 147 path: 'src/client', 148 148 tsConfigPath: 'off', // [!code ++] ··· 158 158 159 159 ```js 160 160 export default { 161 - input: 'https://get.heyapi.dev/hey-api/backend', 161 + input: 'hey-api/backend', // sign up at app.heyapi.dev 162 162 output: { 163 163 clean: false, // [!code ++] 164 164 path: 'src/client',
+23 -23
docs/openapi-ts/configuration/parser.md
··· 16 16 <!-- prettier-ignore-start --> 17 17 ```js 18 18 export default { 19 - input: 'https://get.heyapi.dev/hey-api/backend', 19 + input: 'hey-api/backend', // sign up at app.heyapi.dev 20 20 output: 'src/client', 21 21 parser: { // [!code ++] 22 22 patch: { // [!code ++] ··· 58 58 <!-- prettier-ignore-start --> 59 59 ```js 60 60 export default { 61 - input: 'https://get.heyapi.dev/hey-api/backend', 61 + input: 'hey-api/backend', // sign up at app.heyapi.dev 62 62 output: 'src/client', 63 63 parser: { // [!code ++] 64 64 validate_EXPERIMENTAL: true, // [!code ++] ··· 80 80 <!-- prettier-ignore-start --> 81 81 ```js [include] 82 82 export default { 83 - input: 'https://get.heyapi.dev/hey-api/backend', 83 + input: 'hey-api/backend', // sign up at app.heyapi.dev 84 84 output: 'src/client', 85 85 parser: { // [!code ++] 86 86 filters: { // [!code ++] ··· 95 95 <!-- prettier-ignore-start --> 96 96 ```js [exclude] 97 97 export default { 98 - input: 'https://get.heyapi.dev/hey-api/backend', 98 + input: 'hey-api/backend', // sign up at app.heyapi.dev 99 99 output: 'src/client', 100 100 parser: { // [!code ++] 101 101 filters: { // [!code ++] ··· 119 119 <!-- prettier-ignore-start --> 120 120 ```js [include] 121 121 export default { 122 - input: 'https://get.heyapi.dev/hey-api/backend', 122 + input: 'hey-api/backend', // sign up at app.heyapi.dev 123 123 output: 'src/client', 124 124 parser: { // [!code ++] 125 125 filters: { // [!code ++] ··· 134 134 <!-- prettier-ignore-start --> 135 135 ```js [exclude] 136 136 export default { 137 - input: 'https://get.heyapi.dev/hey-api/backend', 137 + input: 'hey-api/backend', // sign up at app.heyapi.dev 138 138 output: 'src/client', 139 139 parser: { // [!code ++] 140 140 filters: { // [!code ++] ··· 156 156 <!-- prettier-ignore-start --> 157 157 ```js 158 158 export default { 159 - input: 'https://get.heyapi.dev/hey-api/backend', 159 + input: 'hey-api/backend', // sign up at app.heyapi.dev 160 160 output: 'src/client', 161 161 parser: { // [!code ++] 162 162 filters: { // [!code ++] ··· 176 176 <!-- prettier-ignore-start --> 177 177 ```js [include] 178 178 export default { 179 - input: 'https://get.heyapi.dev/hey-api/backend', 179 + input: 'hey-api/backend', // sign up at app.heyapi.dev 180 180 output: 'src/client', 181 181 parser: { // [!code ++] 182 182 filters: { // [!code ++] ··· 191 191 <!-- prettier-ignore-start --> 192 192 ```js [exclude] 193 193 export default { 194 - input: 'https://get.heyapi.dev/hey-api/backend', 194 + input: 'hey-api/backend', // sign up at app.heyapi.dev 195 195 output: 'src/client', 196 196 parser: { // [!code ++] 197 197 filters: { // [!code ++] ··· 215 215 <!-- prettier-ignore-start --> 216 216 ```js [include] 217 217 export default { 218 - input: 'https://get.heyapi.dev/hey-api/backend', 218 + input: 'hey-api/backend', // sign up at app.heyapi.dev 219 219 output: 'src/client', 220 220 parser: { // [!code ++] 221 221 filters: { // [!code ++] ··· 230 230 <!-- prettier-ignore-start --> 231 231 ```js [exclude] 232 232 export default { 233 - input: 'https://get.heyapi.dev/hey-api/backend', 233 + input: 'hey-api/backend', // sign up at app.heyapi.dev 234 234 output: 'src/client', 235 235 parser: { // [!code ++] 236 236 filters: { // [!code ++] ··· 254 254 <!-- prettier-ignore-start --> 255 255 ```js [include] 256 256 export default { 257 - input: 'https://get.heyapi.dev/hey-api/backend', 257 + input: 'hey-api/backend', // sign up at app.heyapi.dev 258 258 output: 'src/client', 259 259 parser: { // [!code ++] 260 260 filters: { // [!code ++] ··· 269 269 <!-- prettier-ignore-start --> 270 270 ```js [exclude] 271 271 export default { 272 - input: 'https://get.heyapi.dev/hey-api/backend', 272 + input: 'hey-api/backend', // sign up at app.heyapi.dev 273 273 output: 'src/client', 274 274 parser: { // [!code ++] 275 275 filters: { // [!code ++] ··· 293 293 <!-- prettier-ignore-start --> 294 294 ```js [include] 295 295 export default { 296 - input: 'https://get.heyapi.dev/hey-api/backend', 296 + input: 'hey-api/backend', // sign up at app.heyapi.dev 297 297 output: 'src/client', 298 298 parser: { // [!code ++] 299 299 filters: { // [!code ++] ··· 308 308 <!-- prettier-ignore-start --> 309 309 ```js [exclude] 310 310 export default { 311 - input: 'https://get.heyapi.dev/hey-api/backend', 311 + input: 'hey-api/backend', // sign up at app.heyapi.dev 312 312 output: 'src/client', 313 313 parser: { // [!code ++] 314 314 filters: { // [!code ++] ··· 330 330 <!-- prettier-ignore-start --> 331 331 ```js 332 332 export default { 333 - input: 'https://get.heyapi.dev/hey-api/backend', 333 + input: 'hey-api/backend', // sign up at app.heyapi.dev 334 334 output: 'src/client', 335 335 parser: { // [!code ++] 336 336 filters: { // [!code ++] ··· 348 348 <!-- prettier-ignore-start --> 349 349 ```js 350 350 export default { 351 - input: 'https://get.heyapi.dev/hey-api/backend', 351 + input: 'hey-api/backend', // sign up at app.heyapi.dev 352 352 output: 'src/client', 353 353 parser: { // [!code ++] 354 354 filters: { // [!code ++] ··· 377 377 <!-- prettier-ignore-start --> 378 378 ```js [root] 379 379 export default { 380 - input: 'https://get.heyapi.dev/hey-api/backend', 380 + input: 'hey-api/backend', // sign up at app.heyapi.dev 381 381 output: 'src/client', 382 382 parser: { // [!code ++] 383 383 transforms: { // [!code ++] ··· 390 390 <!-- prettier-ignore-start --> 391 391 ```js [inline] 392 392 export default { 393 - input: 'https://get.heyapi.dev/hey-api/backend', 393 + input: 'hey-api/backend', // sign up at app.heyapi.dev 394 394 output: 'src/client', 395 395 parser: { // [!code ++] 396 396 transforms: { // [!code ++] ··· 414 414 <!-- prettier-ignore-start --> 415 415 ```js [default] 416 416 export default { 417 - input: 'https://get.heyapi.dev/hey-api/backend', 417 + input: 'hey-api/backend', // sign up at app.heyapi.dev 418 418 output: 'src/client', 419 419 parser: { // [!code ++] 420 420 transforms: { // [!code ++] ··· 430 430 <!-- prettier-ignore-start --> 431 431 ```js [disabled] 432 432 export default { 433 - input: 'https://get.heyapi.dev/hey-api/backend', 433 + input: 'hey-api/backend', // sign up at app.heyapi.dev 434 434 output: 'src/client', 435 435 parser: { // [!code ++] 436 436 transforms: { // [!code ++] ··· 458 458 import { defaultPaginationKeywords } from '@hey-api/openapi-ts'; 459 459 460 460 export default { 461 - input: 'https://get.heyapi.dev/hey-api/backend', 461 + input: 'hey-api/backend', // sign up at app.heyapi.dev 462 462 output: 'src/client', 463 463 parser: { // [!code ++] 464 464 pagination: { // [!code ++] ··· 471 471 <!-- prettier-ignore-start --> 472 472 ```js [override] 473 473 export default { 474 - input: 'https://get.heyapi.dev/hey-api/backend', 474 + input: 'hey-api/backend', // sign up at app.heyapi.dev 475 475 output: 'src/client', 476 476 parser: { // [!code ++] 477 477 pagination: { // [!code ++]
+2 -4
docs/openapi-ts/get-started.md
··· 32 32 The fastest way to use `@hey-api/openapi-ts` is via npx 33 33 34 34 ```sh 35 - npx @hey-api/openapi-ts \ 36 - -i https://get.heyapi.dev/hey-api/backend \ 37 - -o src/client 35 + npx @hey-api/openapi-ts -i hey-api/backend -o src/client 38 36 ``` 39 37 40 38 Congratulations on creating your first client! 🎉 You can learn more about the generated files on the [Output](/openapi-ts/output) page. ··· 99 97 import { createClient } from '@hey-api/openapi-ts'; 100 98 101 99 createClient({ 102 - input: 'https://get.heyapi.dev/hey-api/backend', 100 + input: 'hey-api/backend', // sign up at app.heyapi.dev 103 101 output: 'src/client', 104 102 }); 105 103 ```
+1 -3
docs/openapi-ts/integrations.md
··· 96 96 ::: code-group 97 97 98 98 ```sh [Hey API] 99 - npx @hey-api/openapi-ts \ 100 - -i https://get.heyapi.dev/hey-api/backend \ 101 - -o src/client 99 + npx @hey-api/openapi-ts -i hey-api/backend -o src/client 102 100 ``` 103 101 104 102 ```sh [OpenAPI TypeScript]
+48 -48
docs/openapi-ts/migrating.md
··· 17 17 18 18 ```js [Zod 3] 19 19 export default { 20 - input: 'https://get.heyapi.dev/hey-api/backend', 20 + input: 'hey-api/backend', // sign up at app.heyapi.dev 21 21 output: 'src/client', 22 22 plugins: [ 23 23 // ...other plugins ··· 31 31 32 32 ```js [Zod Mini] 33 33 export default { 34 - input: 'https://get.heyapi.dev/hey-api/backend', 34 + input: 'hey-api/backend', // sign up at app.heyapi.dev 35 35 output: 'src/client', 36 36 plugins: [ 37 37 // ...other plugins ··· 99 99 <!-- prettier-ignore-start --> 100 100 ```js 101 101 export default { 102 - input: 'https://get.heyapi.dev/hey-api/backend', 102 + input: 'hey-api/backend', // sign up at app.heyapi.dev 103 103 output: 'src/client', 104 104 plugins: [ 105 105 // ...other plugins ··· 212 212 213 213 ```js 214 214 export default { 215 - input: 'https://get.heyapi.dev/hey-api/backend', 215 + input: 'hey-api/backend', // sign up at app.heyapi.dev 216 216 output: 'src/client', 217 217 plugins: [ 218 218 // ...other plugins ··· 232 232 233 233 ```js 234 234 export default { 235 - input: 'https://get.heyapi.dev/hey-api/backend', 235 + input: 'hey-api/backend', // sign up at app.heyapi.dev 236 236 output: 'src/client', 237 237 plugins: [ 238 238 // ...other plugins ··· 266 266 }, 267 267 }, 268 268 include: '^(#/components/schemas/foo|#/paths/api/v1/foo/get)$', // [!code --] 269 - path: 'https://get.heyapi.dev/hey-api/backend', 269 + path: 'hey-api/backend', // sign up at app.heyapi.dev 270 270 }, 271 271 output: 'src/client', 272 272 plugins: ['@hey-api/client-fetch'], ··· 286 286 exclude: ['foo'], // [!code ++] 287 287 }, 288 288 }, 289 - path: 'https://get.heyapi.dev/hey-api/backend', 289 + path: 'hey-api/backend', // sign up at app.heyapi.dev 290 290 }, 291 291 output: 'src/client', 292 292 plugins: ['@hey-api/client-fetch'], ··· 303 303 304 304 ```js 305 305 export default { 306 - input: 'https://get.heyapi.dev/hey-api/backend', 306 + input: 'hey-api/backend', // sign up at app.heyapi.dev 307 307 output: { 308 308 path: 'src/client', 309 309 tsConfigPath: 'off', // [!code ++] ··· 319 319 320 320 ```js 321 321 export default { 322 - input: 'https://get.heyapi.dev/hey-api/backend', 322 + input: 'hey-api/backend', // sign up at app.heyapi.dev 323 323 output: 'src/client', 324 324 plugins: [ 325 325 // ...other plugins ··· 348 348 349 349 ```js 350 350 export default { 351 - input: 'https://get.heyapi.dev/hey-api/backend', 351 + input: 'hey-api/backend', // sign up at app.heyapi.dev 352 352 output: 'src/client', 353 353 plugins: [ 354 354 { ··· 368 368 ```js 369 369 export default { 370 370 client: '@hey-api/client-fetch', // [!code --] 371 - input: 'https://get.heyapi.dev/hey-api/backend', 371 + input: 'hey-api/backend', // sign up at app.heyapi.dev 372 372 output: 'src/client', 373 373 plugins: ['@hey-api/client-fetch'], // [!code ++] 374 374 }; ··· 389 389 390 390 ```js 391 391 export default { 392 - input: 'https://get.heyapi.dev/hey-api/backend', 392 + input: 'hey-api/backend', // sign up at app.heyapi.dev 393 393 output: 'src/client', 394 394 plugins: [ 395 395 { ··· 414 414 export default { 415 415 client: '@hey-api/client-fetch', 416 416 experimentalParser: false, // [!code ++] 417 - input: 'https://get.heyapi.dev/hey-api/backend', 417 + input: 'hey-api/backend', // sign up at app.heyapi.dev 418 418 output: 'src/client', 419 419 }; 420 420 ``` ··· 456 456 ```js 457 457 export default { 458 458 client: '@hey-api/client-fetch', 459 - input: 'https://get.heyapi.dev/hey-api/backend', 459 + input: 'hey-api/backend', // sign up at app.heyapi.dev 460 460 output: 'src/client', 461 461 plugins: [ 462 462 // ...other plugins ··· 482 482 export default { 483 483 client: '@hey-api/client-fetch', 484 484 debug: true, // [!code --] 485 - input: 'https://get.heyapi.dev/hey-api/backend', 485 + input: 'hey-api/backend', // sign up at app.heyapi.dev 486 486 logs: { 487 487 level: 'debug', // [!code ++] 488 488 }, ··· 498 498 export default { 499 499 client: '@hey-api/client-fetch', 500 500 experimentalParser: true, 501 - input: 'https://get.heyapi.dev/hey-api/backend', 501 + input: 'hey-api/backend', // sign up at app.heyapi.dev 502 502 output: 'src/client', 503 503 plugins: [ 504 504 // ...other plugins ··· 534 534 ```js 535 535 export default { 536 536 client: '@hey-api/client-fetch', 537 - input: 'https://get.heyapi.dev/hey-api/backend', 537 + input: 'hey-api/backend', // sign up at app.heyapi.dev 538 538 output: { 539 539 clean: false, // [!code ++] 540 540 path: 'src/client', ··· 550 550 export default { 551 551 client: '@hey-api/client-fetch', 552 552 experimentalParser: true, 553 - input: 'https://get.heyapi.dev/hey-api/backend', 553 + input: 'hey-api/backend', // sign up at app.heyapi.dev 554 554 output: 'src/client', 555 555 plugins: [ 556 556 // ...other plugins ··· 591 591 export default { 592 592 client: '@hey-api/client-fetch', 593 593 experimentalParser: true, 594 - input: 'https://get.heyapi.dev/hey-api/backend', 594 + input: 'hey-api/backend', // sign up at app.heyapi.dev 595 595 output: 'src/client', 596 596 plugins: [ 597 597 // ...other plugins ··· 633 633 experimentalParser: true, 634 634 input: { 635 635 include: '^(#/components/schemas/foo|#/paths/api/v1/foo/get)$', // [!code ++] 636 - path: 'https://get.heyapi.dev/hey-api/backend', 636 + path: 'hey-api/backend', // sign up at app.heyapi.dev 637 637 }, 638 638 output: 'src/client', 639 639 }; ··· 658 658 ```js [shorthand] 659 659 export default { 660 660 client: '@hey-api/client-fetch', 661 - input: 'https://get.heyapi.dev/hey-api/backend', 661 + input: 'hey-api/backend', // sign up at app.heyapi.dev 662 662 output: 'src/client', 663 663 schemas: false, // [!code --] 664 664 plugins: ['@hey-api/types', '@hey-api/services'], // [!code ++] ··· 668 668 ```js [*.export] 669 669 export default { 670 670 client: '@hey-api/client-fetch', 671 - input: 'https://get.heyapi.dev/hey-api/backend', 671 + input: 'hey-api/backend', // sign up at app.heyapi.dev 672 672 output: 'src/client', 673 673 schemas: { 674 674 export: false, // [!code --] ··· 686 686 ```js 687 687 export default { 688 688 client: '@hey-api/client-fetch', 689 - input: 'https://get.heyapi.dev/hey-api/backend', 689 + input: 'hey-api/backend', // sign up at app.heyapi.dev 690 690 output: 'src/client', 691 691 schemas: { 692 692 name: (name) => `${name}Schema`, // [!code --] ··· 708 708 ```js 709 709 export default { 710 710 client: '@hey-api/client-fetch', 711 - input: 'https://get.heyapi.dev/hey-api/backend', 711 + input: 'hey-api/backend', // sign up at app.heyapi.dev 712 712 output: 'src/client', 713 713 services: '^MySchema', // [!code --] 714 714 plugins: [ ··· 728 728 ```js 729 729 export default { 730 730 client: '@hey-api/client-fetch', 731 - input: 'https://get.heyapi.dev/hey-api/backend', 731 + input: 'hey-api/backend', // sign up at app.heyapi.dev 732 732 output: 'src/client', 733 733 services: { 734 734 name: '{{name}}Service', // [!code --] ··· 750 750 ```js 751 751 export default { 752 752 client: '@hey-api/client-fetch', 753 - input: 'https://get.heyapi.dev/hey-api/backend', 753 + input: 'hey-api/backend', // sign up at app.heyapi.dev 754 754 output: 'src/client', 755 755 types: { 756 756 dates: 'types+transform', // [!code --] ··· 772 772 ```js 773 773 export default { 774 774 client: '@hey-api/client-fetch', 775 - input: 'https://get.heyapi.dev/hey-api/backend', 775 + input: 'hey-api/backend', // sign up at app.heyapi.dev 776 776 output: 'src/client', 777 777 types: '^MySchema', // [!code --] 778 778 plugins: [ ··· 792 792 ```js 793 793 export default { 794 794 client: '@hey-api/client-fetch', 795 - input: 'https://get.heyapi.dev/hey-api/backend', 795 + input: 'hey-api/backend', // sign up at app.heyapi.dev 796 796 output: 'src/client', 797 797 types: { 798 798 name: 'PascalCase', // [!code --] ··· 815 815 816 816 ```js 817 817 export default { 818 - input: 'https://get.heyapi.dev/hey-api/backend', 818 + input: 'hey-api/backend', // sign up at app.heyapi.dev 819 819 output: 'src/client', 820 820 schemas: { 821 821 name: (name) => `$${name}`, // [!code ++] ··· 833 833 export default { 834 834 client: 'fetch', // [!code --] 835 835 client: 'legacy/fetch', // [!code ++] 836 - input: 'https://get.heyapi.dev/hey-api/backend', 836 + input: 'hey-api/backend', // sign up at app.heyapi.dev 837 837 output: 'src/client', 838 838 }; 839 839 ``` ··· 842 842 export default { 843 843 client: 'axios', // [!code --] 844 844 client: 'legacy/axios', // [!code ++] 845 - input: 'https://get.heyapi.dev/hey-api/backend', 845 + input: 'hey-api/backend', // sign up at app.heyapi.dev 846 846 output: 'src/client', 847 847 }; 848 848 ``` ··· 851 851 export default { 852 852 client: 'angular', // [!code --] 853 853 client: 'legacy/angular', // [!code ++] 854 - input: 'https://get.heyapi.dev/hey-api/backend', 854 + input: 'hey-api/backend', // sign up at app.heyapi.dev 855 855 output: 'src/client', 856 856 }; 857 857 ``` ··· 860 860 export default { 861 861 client: 'node', // [!code --] 862 862 client: 'legacy/node', // [!code ++] 863 - input: 'https://get.heyapi.dev/hey-api/backend', 863 + input: 'hey-api/backend', // sign up at app.heyapi.dev 864 864 output: 'src/client', 865 865 }; 866 866 ``` ··· 869 869 export default { 870 870 client: 'xhr', // [!code --] 871 871 client: 'legacy/xhr', // [!code ++] 872 - input: 'https://get.heyapi.dev/hey-api/backend', 872 + input: 'hey-api/backend', // sign up at app.heyapi.dev 873 873 output: 'src/client', 874 874 }; 875 875 ``` ··· 915 915 ```js 916 916 export default { 917 917 client: 'fetch', // [!code ++] 918 - input: 'https://get.heyapi.dev/hey-api/backend', 918 + input: 'hey-api/backend', // sign up at app.heyapi.dev 919 919 output: 'src/client', 920 920 }; 921 921 ``` ··· 930 930 import { createClient } from '@hey-api/openapi-ts'; 931 931 932 932 createClient({ 933 - input: 'https://get.heyapi.dev/hey-api/backend', 933 + input: 'hey-api/backend', // sign up at app.heyapi.dev 934 934 output: 'src/client', 935 935 services: { 936 936 methodNameBuilder: (service, name) => name, // [!code --] ··· 965 965 966 966 ```js 967 967 export default { 968 - input: 'https://get.heyapi.dev/hey-api/backend', 968 + input: 'hey-api/backend', // sign up at app.heyapi.dev 969 969 output: 'src/client', 970 970 services: { 971 971 asClass: true, // [!code ++] ··· 982 982 ```js 983 983 export default { 984 984 client: 'axios', // [!code ++] 985 - input: 'https://get.heyapi.dev/hey-api/backend', 985 + input: 'hey-api/backend', // sign up at app.heyapi.dev 986 986 output: 'src/client', 987 987 }; 988 988 ``` ··· 996 996 ```js 997 997 export default { 998 998 format: 'prettier', // [!code --] 999 - input: 'https://get.heyapi.dev/hey-api/backend', 999 + input: 'hey-api/backend', // sign up at app.heyapi.dev 1000 1000 output: { 1001 1001 format: 'prettier', // [!code ++] 1002 1002 path: 'src/client', ··· 1010 1010 1011 1011 ```js 1012 1012 export default { 1013 - input: 'https://get.heyapi.dev/hey-api/backend', 1013 + input: 'hey-api/backend', // sign up at app.heyapi.dev 1014 1014 lint: 'eslint', // [!code --] 1015 1015 output: { 1016 1016 lint: 'eslint', // [!code ++] ··· 1057 1057 ```js 1058 1058 export default { 1059 1059 enums: 'javascript', // [!code --] 1060 - input: 'https://get.heyapi.dev/hey-api/backend', 1060 + input: 'hey-api/backend', // sign up at app.heyapi.dev 1061 1061 output: 'src/client', 1062 1062 types: { 1063 1063 enums: 'javascript', // [!code ++] ··· 1074 1074 ```js{2} 1075 1075 export default { 1076 1076 format: 'prettier', 1077 - input: 'https://get.heyapi.dev/hey-api/backend', 1077 + input: 'hey-api/backend', // sign up at app.heyapi.dev 1078 1078 output: 'src/client', 1079 1079 } 1080 1080 ``` ··· 1085 1085 1086 1086 ```js{3} 1087 1087 export default { 1088 - input: 'https://get.heyapi.dev/hey-api/backend', 1088 + input: 'hey-api/backend', // sign up at app.heyapi.dev 1089 1089 lint: 'eslint', 1090 1090 output: 'src/client', 1091 1091 } ··· 1097 1097 1098 1098 ```js{5} 1099 1099 export default { 1100 - input: 'https://get.heyapi.dev/hey-api/backend', 1100 + input: 'hey-api/backend', // sign up at app.heyapi.dev 1101 1101 output: 'src/client', 1102 1102 services: { 1103 1103 operationId: true, ··· 1113 1113 1114 1114 ```js{5} 1115 1115 export default { 1116 - input: 'https://get.heyapi.dev/hey-api/backend', 1116 + input: 'hey-api/backend', // sign up at app.heyapi.dev 1117 1117 output: 'src/client', 1118 1118 services: { 1119 1119 name: 'myAwesome{{name}}Api', ··· 1127 1127 1128 1128 ```js{5} 1129 1129 export default { 1130 - input: 'https://get.heyapi.dev/hey-api/backend', 1130 + input: 'hey-api/backend', // sign up at app.heyapi.dev 1131 1131 output: 'src/client', 1132 1132 services: { 1133 1133 response: 'body', ··· 1141 1141 1142 1142 ```js{5} 1143 1143 export default { 1144 - input: 'https://get.heyapi.dev/hey-api/backend', 1144 + input: 'hey-api/backend', // sign up at app.heyapi.dev 1145 1145 output: 'src/client', 1146 1146 type: { 1147 1147 dates: true, ··· 1170 1170 1171 1171 ```js{5} 1172 1172 export default { 1173 - input: 'https://get.heyapi.dev/hey-api/backend', 1173 + input: 'hey-api/backend', // sign up at app.heyapi.dev 1174 1174 output: 'src/client', 1175 1175 types: { 1176 1176 name: 'PascalCase',
+2 -2
docs/openapi-ts/output.md
··· 61 61 62 62 ```js 63 63 export default { 64 - input: 'https://get.heyapi.dev/hey-api/backend', 64 + input: 'hey-api/backend', // sign up at app.heyapi.dev 65 65 output: { 66 66 indexFile: false, // [!code ++] 67 67 path: 'src/client', ··· 75 75 76 76 ```js 77 77 export default { 78 - input: 'https://get.heyapi.dev/hey-api/backend', 78 + input: 'hey-api/backend', // sign up at app.heyapi.dev 79 79 output: 'src/client', 80 80 plugins: [ 81 81 // ...other plugins
+3 -3
docs/openapi-ts/output/json-schema.md
··· 15 15 16 16 ```js [json] 17 17 export default { 18 - input: 'https://get.heyapi.dev/hey-api/backend', 18 + input: 'hey-api/backend', // sign up at app.heyapi.dev 19 19 output: 'src/client', 20 20 plugins: [ 21 21 // ...other plugins ··· 29 29 30 30 ```js [form] 31 31 export default { 32 - input: 'https://get.heyapi.dev/hey-api/backend', 32 + input: 'hey-api/backend', // sign up at app.heyapi.dev 33 33 output: 'src/client', 34 34 plugins: [ 35 35 // ...other plugins ··· 43 43 44 44 ```js [disabled] 45 45 export default { 46 - input: 'https://get.heyapi.dev/hey-api/backend', 46 + input: 'hey-api/backend', // sign up at app.heyapi.dev 47 47 output: 'src/client', 48 48 plugins: [ 49 49 // ...other plugins
+7 -7
docs/openapi-ts/output/sdk.md
··· 27 27 28 28 ```js [flat] 29 29 export default { 30 - input: 'https://get.heyapi.dev/hey-api/backend', 30 + input: 'hey-api/backend', // sign up at app.heyapi.dev 31 31 output: 'src/client', 32 32 plugins: [ 33 33 // ...other plugins ··· 41 41 42 42 ```js [class] 43 43 export default { 44 - input: 'https://get.heyapi.dev/hey-api/backend', 44 + input: 'hey-api/backend', // sign up at app.heyapi.dev 45 45 output: 'src/client', 46 46 plugins: [ 47 47 // ...other plugins ··· 55 55 56 56 ```js [none] 57 57 export default { 58 - input: 'https://get.heyapi.dev/hey-api/backend', 58 + input: 'hey-api/backend', // sign up at app.heyapi.dev 59 59 output: 'src/client', 60 60 plugins: [ 61 61 '@hey-api/typescript', ··· 152 152 153 153 ```js [sdk] 154 154 export default { 155 - input: 'https://get.heyapi.dev/hey-api/backend', 155 + input: 'hey-api/backend', // sign up at app.heyapi.dev 156 156 output: 'src/client', 157 157 plugins: [ 158 158 { ··· 165 165 166 166 ```js [validator] 167 167 export default { 168 - input: 'https://get.heyapi.dev/hey-api/backend', 168 + input: 'hey-api/backend', // sign up at app.heyapi.dev 169 169 output: 'src/client', 170 170 plugins: [ 171 171 { ··· 188 188 189 189 ```js [requests] 190 190 export default { 191 - input: 'https://get.heyapi.dev/hey-api/backend', 191 + input: 'hey-api/backend', // sign up at app.heyapi.dev 192 192 output: 'src/client', 193 193 plugins: [ 194 194 { ··· 203 203 204 204 ```js [responses] 205 205 export default { 206 - input: 'https://get.heyapi.dev/hey-api/backend', 206 + input: 'hey-api/backend', // sign up at app.heyapi.dev 207 207 output: 'src/client', 208 208 plugins: [ 209 209 {
+4 -4
docs/openapi-ts/output/typescript.md
··· 13 13 14 14 ```js 15 15 export default { 16 - input: 'https://get.heyapi.dev/hey-api/backend', 16 + input: 'hey-api/backend', // sign up at app.heyapi.dev 17 17 output: 'src/client', 18 18 plugins: [ 19 19 // ...other plugins ··· 86 86 87 87 ```js [disabled] 88 88 export default { 89 - input: 'https://get.heyapi.dev/hey-api/backend', 89 + input: 'hey-api/backend', // sign up at app.heyapi.dev 90 90 output: 'src/client', 91 91 plugins: [ 92 92 // ...other plugins ··· 100 100 101 101 ```js [javascript] 102 102 export default { 103 - input: 'https://get.heyapi.dev/hey-api/backend', 103 + input: 'hey-api/backend', // sign up at app.heyapi.dev 104 104 output: 'src/client', 105 105 plugins: [ 106 106 // ...other plugins ··· 114 114 115 115 ```js [typescript] 116 116 export default { 117 - input: 'https://get.heyapi.dev/hey-api/backend', 117 + input: 'hey-api/backend', // sign up at app.heyapi.dev 118 118 output: 'src/client', 119 119 plugins: [ 120 120 // ...other plugins
+3 -3
docs/openapi-ts/plugins/angular.md
··· 43 43 44 44 ```js 45 45 export default { 46 - input: 'https://get.heyapi.dev/hey-api/backend', 46 + input: 'hey-api/backend', // sign up at app.heyapi.dev 47 47 output: 'src/client', 48 48 plugins: [ 49 49 // ...other plugins ··· 74 74 75 75 ```js [config] 76 76 export default { 77 - input: 'https://get.heyapi.dev/hey-api/backend', 77 + input: 'hey-api/backend', // sign up at app.heyapi.dev 78 78 output: 'src/client', 79 79 plugins: [ 80 80 // ...other plugins ··· 101 101 102 102 ```js [config] 103 103 export default { 104 - input: 'https://get.heyapi.dev/hey-api/backend', 104 + input: 'hey-api/backend', // sign up at app.heyapi.dev 105 105 output: 'src/client', 106 106 plugins: [ 107 107 // ...other plugins
+3 -3
docs/openapi-ts/plugins/angular/v19.md
··· 43 43 44 44 ```js 45 45 export default { 46 - input: 'https://get.heyapi.dev/hey-api/backend', 46 + input: 'hey-api/backend', // sign up at app.heyapi.dev 47 47 output: 'src/client', 48 48 plugins: [ 49 49 // ...other plugins ··· 74 74 75 75 ```js [config] 76 76 export default { 77 - input: 'https://get.heyapi.dev/hey-api/backend', 77 + input: 'hey-api/backend', // sign up at app.heyapi.dev 78 78 output: 'src/client', 79 79 plugins: [ 80 80 // ...other plugins ··· 101 101 102 102 ```js [config] 103 103 export default { 104 - input: 'https://get.heyapi.dev/hey-api/backend', 104 + input: 'hey-api/backend', // sign up at app.heyapi.dev 105 105 output: 'src/client', 106 106 plugins: [ 107 107 // ...other plugins
+1 -1
docs/openapi-ts/plugins/custom.md
··· 155 155 import { defineConfig } from 'path/to/my-plugin'; 156 156 157 157 export default { 158 - input: 'https://get.heyapi.dev/hey-api/backend', 158 + input: 'hey-api/backend', // sign up at app.heyapi.dev 159 159 output: 'src/client', 160 160 plugins: [ 161 161 defineConfig({
+2 -2
docs/openapi-ts/plugins/fastify.md
··· 42 42 43 43 ```js 44 44 export default { 45 - input: 'https://get.heyapi.dev/hey-api/backend', 45 + input: 'hey-api/backend', // sign up at app.heyapi.dev 46 46 output: 'src/client', 47 47 plugins: [ 48 48 // ...other plugins ··· 82 82 83 83 ```js [config] 84 84 export default { 85 - input: 'https://get.heyapi.dev/hey-api/backend', 85 + input: 'hey-api/backend', // sign up at app.heyapi.dev 86 86 output: 'src/client', 87 87 plugins: [ 88 88 // ...other plugins
+23 -23
docs/openapi-ts/plugins/tanstack-query.md
··· 43 43 44 44 ```js [react] 45 45 export default { 46 - input: 'https://get.heyapi.dev/hey-api/backend', 46 + input: 'hey-api/backend', // sign up at app.heyapi.dev 47 47 output: 'src/client', 48 48 plugins: [ 49 49 // ...other plugins ··· 54 54 55 55 ```js [vue] 56 56 export default { 57 - input: 'https://get.heyapi.dev/hey-api/backend', 57 + input: 'hey-api/backend', // sign up at app.heyapi.dev 58 58 output: 'src/client', 59 59 plugins: [ 60 60 // ...other plugins ··· 65 65 66 66 ```js [angular] 67 67 export default { 68 - input: 'https://get.heyapi.dev/hey-api/backend', 68 + input: 'hey-api/backend', // sign up at app.heyapi.dev 69 69 output: 'src/client', 70 70 plugins: [ 71 71 // ...other plugins ··· 76 76 77 77 ```js [svelte] 78 78 export default { 79 - input: 'https://get.heyapi.dev/hey-api/backend', 79 + input: 'hey-api/backend', // sign up at app.heyapi.dev 80 80 output: 'src/client', 81 81 plugins: [ 82 82 // ...other plugins ··· 87 87 88 88 ```js [solid] 89 89 export default { 90 - input: 'https://get.heyapi.dev/hey-api/backend', 90 + input: 'hey-api/backend', // sign up at app.heyapi.dev 91 91 output: 'src/client', 92 92 plugins: [ 93 93 // ...other plugins ··· 120 120 121 121 ```js [config] 122 122 export default { 123 - input: 'https://get.heyapi.dev/hey-api/backend', 123 + input: 'hey-api/backend', // sign up at app.heyapi.dev 124 124 output: 'src/client', 125 125 plugins: [ 126 126 // ...other plugins ··· 153 153 154 154 ```js [config] 155 155 export default { 156 - input: 'https://get.heyapi.dev/hey-api/backend', 156 + input: 'hey-api/backend', // sign up at app.heyapi.dev 157 157 output: 'src/client', 158 158 plugins: [ 159 159 // ...other plugins ··· 179 179 const queryKey = [ 180 180 { 181 181 _id: 'getPetById', 182 - baseUrl: 'https://get.heyapi.dev', 182 + baseUrl: 'https://app.heyapi.dev', 183 183 path: { 184 184 petId: 1, 185 185 }, ··· 189 189 190 190 ```js [config] 191 191 export default { 192 - input: 'https://get.heyapi.dev/hey-api/backend', 192 + input: 'hey-api/backend', // sign up at app.heyapi.dev 193 193 output: 'src/client', 194 194 plugins: [ 195 195 // ...other plugins ··· 213 213 const queryKey = [ 214 214 { 215 215 _id: 'getPetById', 216 - baseUrl: 'https://get.heyapi.dev', 216 + baseUrl: 'https://app.heyapi.dev', 217 217 path: { 218 218 petId: 1, 219 219 }, ··· 224 224 225 225 ```js [config] 226 226 export default { 227 - input: 'https://get.heyapi.dev/hey-api/backend', 227 + input: 'hey-api/backend', // sign up at app.heyapi.dev 228 228 output: 'src/client', 229 229 plugins: [ 230 230 // ...other plugins ··· 256 256 257 257 ```js [config] 258 258 export default { 259 - input: 'https://get.heyapi.dev/hey-api/backend', 259 + input: 'hey-api/backend', // sign up at app.heyapi.dev 260 260 output: 'src/client', 261 261 plugins: [ 262 262 // ...other plugins ··· 284 284 285 285 ```js [config] 286 286 export default { 287 - input: 'https://get.heyapi.dev/hey-api/backend', 287 + input: 'hey-api/backend', // sign up at app.heyapi.dev 288 288 output: 'src/client', 289 289 plugins: [ 290 290 // ...other plugins ··· 320 320 321 321 ```js [config] 322 322 export default { 323 - input: 'https://get.heyapi.dev/hey-api/backend', 323 + input: 'hey-api/backend', // sign up at app.heyapi.dev 324 324 output: 'src/client', 325 325 plugins: [ 326 326 // ...other plugins ··· 353 353 354 354 ```js [config] 355 355 export default { 356 - input: 'https://get.heyapi.dev/hey-api/backend', 356 + input: 'hey-api/backend', // sign up at app.heyapi.dev 357 357 output: 'src/client', 358 358 plugins: [ 359 359 // ...other plugins ··· 380 380 { 381 381 _id: 'getPetById', 382 382 _infinite: true, 383 - baseUrl: 'https://get.heyapi.dev', 383 + baseUrl: 'https://app.heyapi.dev', 384 384 path: { 385 385 petId: 1, 386 386 }, ··· 390 390 391 391 ```js [config] 392 392 export default { 393 - input: 'https://get.heyapi.dev/hey-api/backend', 393 + input: 'hey-api/backend', // sign up at app.heyapi.dev 394 394 output: 'src/client', 395 395 plugins: [ 396 396 // ...other plugins ··· 415 415 { 416 416 _id: 'getPetById', 417 417 _infinite: true, 418 - baseUrl: 'https://get.heyapi.dev', 418 + baseUrl: 'https://app.heyapi.dev', 419 419 path: { 420 420 petId: 1, 421 421 }, ··· 426 426 427 427 ```js [config] 428 428 export default { 429 - input: 'https://get.heyapi.dev/hey-api/backend', 429 + input: 'hey-api/backend', // sign up at app.heyapi.dev 430 430 output: 'src/client', 431 431 plugins: [ 432 432 // ...other plugins ··· 458 458 459 459 ```js [config] 460 460 export default { 461 - input: 'https://get.heyapi.dev/hey-api/backend', 461 + input: 'hey-api/backend', // sign up at app.heyapi.dev 462 462 output: 'src/client', 463 463 plugins: [ 464 464 // ...other plugins ··· 486 486 487 487 ```js [config] 488 488 export default { 489 - input: 'https://get.heyapi.dev/hey-api/backend', 489 + input: 'hey-api/backend', // sign up at app.heyapi.dev 490 490 output: 'src/client', 491 491 plugins: [ 492 492 // ...other plugins ··· 525 525 526 526 ```js [config] 527 527 export default { 528 - input: 'https://get.heyapi.dev/hey-api/backend', 528 + input: 'hey-api/backend', // sign up at app.heyapi.dev 529 529 output: 'src/client', 530 530 plugins: [ 531 531 // ...other plugins ··· 558 558 559 559 ```js [config] 560 560 export default { 561 - input: 'https://get.heyapi.dev/hey-api/backend', 561 + input: 'hey-api/backend', // sign up at app.heyapi.dev 562 562 output: 'src/client', 563 563 plugins: [ 564 564 // ...other plugins
+6 -6
docs/openapi-ts/plugins/valibot.md
··· 31 31 32 32 ```js 33 33 export default { 34 - input: 'https://get.heyapi.dev/hey-api/backend', 34 + input: 'hey-api/backend', // sign up at app.heyapi.dev 35 35 output: 'src/client', 36 36 plugins: [ 37 37 // ...other plugins ··· 46 46 47 47 ```js 48 48 export default { 49 - input: 'https://get.heyapi.dev/hey-api/backend', 49 + input: 'hey-api/backend', // sign up at app.heyapi.dev 50 50 output: 'src/client', 51 51 plugins: [ 52 52 // ...other plugins ··· 88 88 89 89 ```js [config] 90 90 export default { 91 - input: 'https://get.heyapi.dev/hey-api/backend', 91 + input: 'hey-api/backend', // sign up at app.heyapi.dev 92 92 output: 'src/client', 93 93 plugins: [ 94 94 // ...other plugins ··· 127 127 128 128 ```js [config] 129 129 export default { 130 - input: 'https://get.heyapi.dev/hey-api/backend', 130 + input: 'hey-api/backend', // sign up at app.heyapi.dev 131 131 output: 'src/client', 132 132 plugins: [ 133 133 // ...other plugins ··· 159 159 160 160 ```js [config] 161 161 export default { 162 - input: 'https://get.heyapi.dev/hey-api/backend', 162 + input: 'hey-api/backend', // sign up at app.heyapi.dev 163 163 output: 'src/client', 164 164 plugins: [ 165 165 // ...other plugins ··· 192 192 193 193 ```js [config] 194 194 export default { 195 - input: 'https://get.heyapi.dev/hey-api/backend', 195 + input: 'hey-api/backend', // sign up at app.heyapi.dev 196 196 output: 'src/client', 197 197 plugins: [ 198 198 // ...other plugins
+7 -7
docs/openapi-ts/plugins/zod.md
··· 31 31 32 32 ```js 33 33 export default { 34 - input: 'https://get.heyapi.dev/hey-api/backend', 34 + input: 'hey-api/backend', // sign up at app.heyapi.dev 35 35 output: 'src/client', 36 36 plugins: [ 37 37 // ...other plugins ··· 46 46 47 47 ```js 48 48 export default { 49 - input: 'https://get.heyapi.dev/hey-api/backend', 49 + input: 'hey-api/backend', // sign up at app.heyapi.dev 50 50 output: 'src/client', 51 51 plugins: [ 52 52 // ...other plugins ··· 88 88 89 89 ```js [config] 90 90 export default { 91 - input: 'https://get.heyapi.dev/hey-api/backend', 91 + input: 'hey-api/backend', // sign up at app.heyapi.dev 92 92 output: 'src/client', 93 93 plugins: [ 94 94 // ...other plugins ··· 127 127 128 128 ```js [config] 129 129 export default { 130 - input: 'https://get.heyapi.dev/hey-api/backend', 130 + input: 'hey-api/backend', // sign up at app.heyapi.dev 131 131 output: 'src/client', 132 132 plugins: [ 133 133 // ...other plugins ··· 159 159 160 160 ```js [config] 161 161 export default { 162 - input: 'https://get.heyapi.dev/hey-api/backend', 162 + input: 'hey-api/backend', // sign up at app.heyapi.dev 163 163 output: 'src/client', 164 164 plugins: [ 165 165 // ...other plugins ··· 189 189 190 190 ```js [config] 191 191 export default { 192 - input: 'https://get.heyapi.dev/hey-api/backend', 192 + input: 'hey-api/backend', // sign up at app.heyapi.dev 193 193 output: 'src/client', 194 194 plugins: [ 195 195 // ...other plugins ··· 215 215 216 216 ```js [config] 217 217 export default { 218 - input: 'https://get.heyapi.dev/hey-api/backend', 218 + input: 'hey-api/backend', // sign up at app.heyapi.dev 219 219 output: 'src/client', 220 220 plugins: [ 221 221 // ...other plugins
+7 -7
docs/openapi-ts/plugins/zod/mini.md
··· 31 31 32 32 ```js 33 33 export default { 34 - input: 'https://get.heyapi.dev/hey-api/backend', 34 + input: 'hey-api/backend', // sign up at app.heyapi.dev 35 35 output: 'src/client', 36 36 plugins: [ 37 37 // ...other plugins ··· 49 49 50 50 ```js 51 51 export default { 52 - input: 'https://get.heyapi.dev/hey-api/backend', 52 + input: 'hey-api/backend', // sign up at app.heyapi.dev 53 53 output: 'src/client', 54 54 plugins: [ 55 55 // ...other plugins ··· 91 91 92 92 ```js [config] 93 93 export default { 94 - input: 'https://get.heyapi.dev/hey-api/backend', 94 + input: 'hey-api/backend', // sign up at app.heyapi.dev 95 95 output: 'src/client', 96 96 plugins: [ 97 97 // ...other plugins ··· 130 130 131 131 ```js [config] 132 132 export default { 133 - input: 'https://get.heyapi.dev/hey-api/backend', 133 + input: 'hey-api/backend', // sign up at app.heyapi.dev 134 134 output: 'src/client', 135 135 plugins: [ 136 136 // ...other plugins ··· 162 162 163 163 ```js [config] 164 164 export default { 165 - input: 'https://get.heyapi.dev/hey-api/backend', 165 + input: 'hey-api/backend', // sign up at app.heyapi.dev 166 166 output: 'src/client', 167 167 plugins: [ 168 168 // ...other plugins ··· 192 192 193 193 ```js [config] 194 194 export default { 195 - input: 'https://get.heyapi.dev/hey-api/backend', 195 + input: 'hey-api/backend', // sign up at app.heyapi.dev 196 196 output: 'src/client', 197 197 plugins: [ 198 198 // ...other plugins ··· 218 218 219 219 ```js [config] 220 220 export default { 221 - input: 'https://get.heyapi.dev/hey-api/backend', 221 + input: 'hey-api/backend', // sign up at app.heyapi.dev 222 222 output: 'src/client', 223 223 plugins: [ 224 224 // ...other plugins
+7 -7
docs/openapi-ts/plugins/zod/v3.md
··· 31 31 32 32 ```js 33 33 export default { 34 - input: 'https://get.heyapi.dev/hey-api/backend', 34 + input: 'hey-api/backend', // sign up at app.heyapi.dev 35 35 output: 'src/client', 36 36 plugins: [ 37 37 // ...other plugins ··· 49 49 50 50 ```js 51 51 export default { 52 - input: 'https://get.heyapi.dev/hey-api/backend', 52 + input: 'hey-api/backend', // sign up at app.heyapi.dev 53 53 output: 'src/client', 54 54 plugins: [ 55 55 // ...other plugins ··· 91 91 92 92 ```js [config] 93 93 export default { 94 - input: 'https://get.heyapi.dev/hey-api/backend', 94 + input: 'hey-api/backend', // sign up at app.heyapi.dev 95 95 output: 'src/client', 96 96 plugins: [ 97 97 // ...other plugins ··· 130 130 131 131 ```js [config] 132 132 export default { 133 - input: 'https://get.heyapi.dev/hey-api/backend', 133 + input: 'hey-api/backend', // sign up at app.heyapi.dev 134 134 output: 'src/client', 135 135 plugins: [ 136 136 // ...other plugins ··· 162 162 163 163 ```js [config] 164 164 export default { 165 - input: 'https://get.heyapi.dev/hey-api/backend', 165 + input: 'hey-api/backend', // sign up at app.heyapi.dev 166 166 output: 'src/client', 167 167 plugins: [ 168 168 // ...other plugins ··· 190 190 191 191 ```js [config] 192 192 export default { 193 - input: 'https://get.heyapi.dev/hey-api/backend', 193 + input: 'hey-api/backend', // sign up at app.heyapi.dev 194 194 output: 'src/client', 195 195 plugins: [ 196 196 // ...other plugins ··· 216 216 217 217 ```js [config] 218 218 export default { 219 - input: 'https://get.heyapi.dev/hey-api/backend', 219 + input: 'hey-api/backend', // sign up at app.heyapi.dev 220 220 output: 'src/client', 221 221 plugins: [ 222 222 // ...other plugins
+3 -3
docs/openapi-ts/transformers.md
··· 33 33 34 34 ```js 35 35 export default { 36 - input: 'https://get.heyapi.dev/hey-api/backend', 36 + input: 'hey-api/backend', // sign up at app.heyapi.dev 37 37 output: 'src/client', 38 38 plugins: [ 39 39 // ...other plugins ··· 48 48 49 49 ```js 50 50 export default { 51 - input: 'https://get.heyapi.dev/hey-api/backend', 51 + input: 'hey-api/backend', // sign up at app.heyapi.dev 52 52 output: 'src/client', 53 53 plugins: [ 54 54 // ...other plugins ··· 67 67 68 68 ```js 69 69 export default { 70 - input: 'https://get.heyapi.dev/hey-api/backend', 70 + input: 'hey-api/backend', // sign up at app.heyapi.dev 71 71 output: 'src/client', 72 72 plugins: [ 73 73 // ...other plugins
+7 -2
examples/openapi-ts-openai/src/App.tsx
··· 36 36 const [isRequiredNameError] = useState(false); 37 37 38 38 const onCreateResponse = async (values: FormData) => { 39 - const response = await sdk.responses.create({ 39 + const stream = await sdk.responses.create({ 40 40 input: values.get('input') as string, 41 41 model: 'gpt-5-nano', 42 + stream: true, 42 43 }); 43 44 44 - console.log(response.output_text); 45 + for await (const event of stream) { 46 + console.log(event); 47 + } 48 + 45 49 const { data, error } = await client.createResponse({ 46 50 body: { 47 51 input: values.get('input') as string, 48 52 model: 'gpt-5-nano', 53 + stream: true, 49 54 }, 50 55 }); 51 56 if (error) {
+3 -2
packages/openapi-ts-tests/main/test/openapi-ts.config.ts
··· 39 39 // 'full.yaml', 40 40 // 'validators-circular-ref.json', 41 41 ), 42 + // path: 'hey-api/backend', 43 + // path: 'hey-api/backend?branch=main&version=1.0.0', 44 + // path: 'https://get.heyapi.dev/hey-api/backend?branch=main&version=1.0.0', 42 45 // path: 'http://localhost:4000/', 43 - // path: 'https://get.heyapi.dev/', 44 - // path: 'https://get.heyapi.dev/hey-api/backend?branch=main&version=1.0.0', 45 46 // path: 'http://localhost:8000/openapi.json', 46 47 // path: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', 47 48 // path: 'https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml',
+9 -9
packages/openapi-ts/CHANGELOG.md
··· 116 116 117 117 ```js 118 118 export default { 119 - input: 'https://get.heyapi.dev/hey-api/backend', 119 + input: 'hey-api/backend', // sign up at app.heyapi.dev 120 120 output: 'src/client', 121 121 plugins: [ 122 122 // ...other plugins ··· 130 130 131 131 ```js 132 132 export default { 133 - input: 'https://get.heyapi.dev/hey-api/backend', 133 + input: 'hey-api/backend', // sign up at app.heyapi.dev 134 134 output: 'src/client', 135 135 plugins: [ 136 136 // ...other plugins ··· 261 261 262 262 ```js 263 263 export default { 264 - input: 'https://get.heyapi.dev/hey-api/backend', 264 + input: 'hey-api/backend', // sign up at app.heyapi.dev 265 265 output: 'src/client', 266 266 plugins: [ 267 267 // ...other plugins ··· 438 438 439 439 ```js 440 440 export default { 441 - input: 'https://get.heyapi.dev/hey-api/backend', 441 + input: 'hey-api/backend', // sign up at app.heyapi.dev 442 442 output: 'src/client', 443 443 plugins: [ 444 444 // ...other plugins ··· 625 625 626 626 ```js 627 627 export default { 628 - input: 'https://get.heyapi.dev/hey-api/backend', 628 + input: 'hey-api/backend', // sign up at app.heyapi.dev 629 629 output: { 630 630 path: 'src/client', 631 631 tsConfigPath: 'off', ··· 717 717 718 718 ```js 719 719 export default { 720 - input: 'https://get.heyapi.dev/hey-api/backend', 720 + input: 'hey-api/backend', // sign up at app.heyapi.dev 721 721 output: 'src/client', 722 722 plugins: [ 723 723 // ...other plugins ··· 2854 2854 - Better handling of services without tags 2855 2855 - Updated dependencies 2856 2856 , // [!code --] 2857 - path: 'https://get.heyapi.dev/hey-api/backend', 2857 + path: 'hey-api/backend', // sign up at app.heyapi.dev 2858 2858 }, 2859 2859 output: 'src/client', 2860 2860 plugins: ['@hey-api/client-fetch'], ··· 2926 2926 2927 2927 ```js 2928 2928 export default { 2929 - input: 'https://get.heyapi.dev/hey-api/backend', 2929 + input: 'hey-api/backend', // sign up at app.heyapi.dev 2930 2930 output: { 2931 2931 path: 'src/client', 2932 2932 tsConfigPath: 'off', ··· 3018 3018 3019 3019 ```js 3020 3020 export default { 3021 - input: 'https://get.heyapi.dev/hey-api/backend', 3021 + input: 'hey-api/backend', // sign up at app.heyapi.dev 3022 3022 output: 'src/client', 3023 3023 plugins: [ 3024 3024 // ...other plugins
+5 -7
packages/openapi-ts/README.md
··· 144 144 The fastest way to use `@hey-api/openapi-ts` is via npx 145 145 146 146 ```sh 147 - npx @hey-api/openapi-ts \ 148 - -i https://get.heyapi.dev/hey-api/backend \ 149 - -o src/client 147 + npx @hey-api/openapi-ts -i hey-api/backend -o src/client 150 148 ``` 151 149 152 150 Congratulations on creating your first client! 🎉 You can learn more about the generated files on the [Output](https://heyapi.dev/openapi-ts/output) page. ··· 213 211 import { createClient } from '@hey-api/openapi-ts'; 214 212 215 213 createClient({ 216 - input: 'https://get.heyapi.dev/hey-api/backend', 214 + input: 'hey-api/backend', // sign up at app.heyapi.dev 217 215 output: 'src/client', 218 216 }); 219 217 ``` ··· 228 226 import { defineConfig } from '@hey-api/openapi-ts'; 229 227 230 228 export default defineConfig({ 231 - input: 'https://get.heyapi.dev/hey-api/backend', 229 + input: 'hey-api/backend', // sign up at app.heyapi.dev 232 230 output: 'src/client', 233 231 }); 234 232 ``` ··· 238 236 ```js 239 237 /** @type {import('@hey-api/openapi-ts').UserConfig} */ 240 238 module.exports = { 241 - input: 'https://get.heyapi.dev/hey-api/backend', 239 + input: 'hey-api/backend', // sign up at app.heyapi.dev 242 240 output: 'src/client', 243 241 }; 244 242 ``` ··· 248 246 ```js 249 247 /** @type {import('@hey-api/openapi-ts').UserConfig} */ 250 248 export default { 251 - input: 'https://get.heyapi.dev/hey-api/backend', 249 + input: 'hey-api/backend', // sign up at app.heyapi.dev 252 250 output: 'src/client', 253 251 }; 254 252 ```
+10 -4
packages/openapi-ts/src/config/__tests__/input.test.ts
··· 96 96 }; 97 97 98 98 const result = getInput(userConfig); 99 - expect(result.path).toBe('https://get.heyapi.dev'); 99 + expect(result.path).toBe('https://get.heyapi.dev/myorg/myproject'); 100 100 }); 101 101 102 102 it('should handle object input (existing functionality)', () => { ··· 178 178 output: 'src/client', 179 179 }; 180 180 181 - expect(() => getInput(userConfig)).toThrow('Invalid ReadMe input format'); 181 + expect(() => getInput(userConfig)).toThrow( 182 + 'Invalid ReadMe shorthand format', 183 + ); 182 184 }); 183 185 184 186 it('should throw error for invalid ReadMe UUID', () => { ··· 187 189 output: 'src/client', 188 190 }; 189 191 190 - expect(() => getInput(userConfig)).toThrow('Invalid ReadMe input format'); 192 + expect(() => getInput(userConfig)).toThrow( 193 + 'Invalid ReadMe shorthand format', 194 + ); 191 195 }); 192 196 193 197 it('should throw error for invalid ReadMe format in object input', () => { ··· 198 202 output: 'src/client', 199 203 }; 200 204 201 - expect(() => getInput(userConfig)).toThrow('Invalid ReadMe input format'); 205 + expect(() => getInput(userConfig)).toThrow( 206 + 'Invalid ReadMe shorthand format', 207 + ); 202 208 }); 203 209 }); 204 210 });
+25 -13
packages/openapi-ts/src/config/input.ts
··· 1 1 import type { Config, UserConfig } from '../types/config'; 2 - import { isReadmeInput, transformReadmeInput } from '../utils/readme'; 2 + import type { Input } from '../types/input'; 3 + import { 4 + heyApiRegistryBaseUrl, 5 + inputToHeyApiPath, 6 + } from '../utils/input/heyApi'; 7 + import { inputToReadmePath } from '../utils/input/readme'; 3 8 4 9 const defaultWatch: Config['input']['watch'] = { 5 10 enabled: false, ··· 39 44 }; 40 45 41 46 if (typeof userConfig.input === 'string') { 42 - // Handle ReadMe input format transformation 43 - if (isReadmeInput(userConfig.input)) { 44 - input.path = transformReadmeInput(userConfig.input); 45 - } else { 46 - input.path = userConfig.input; 47 - } 47 + input.path = userConfig.input; 48 48 } else if ( 49 49 userConfig.input && 50 50 (userConfig.input.path !== undefined || ··· 53 53 // @ts-expect-error 54 54 input = { 55 55 ...input, 56 - path: 'https://get.heyapi.dev', 56 + path: heyApiRegistryBaseUrl, 57 57 ...userConfig.input, 58 58 }; 59 59 60 - // Handle ReadMe input format transformation when path is specified 61 - if (typeof input.path === 'string' && isReadmeInput(input.path)) { 62 - input.path = transformReadmeInput(input.path); 63 - } 64 - 65 60 // watch only remote files 66 61 if (input.watch !== undefined) { 67 62 input.watch = getWatch(input); ··· 71 66 ...input, 72 67 path: userConfig.input as Record<string, unknown>, 73 68 }; 69 + } 70 + 71 + if (typeof input.path === 'string') { 72 + if (input.path.startsWith('readme:')) { 73 + input.path = inputToReadmePath(input.path); 74 + } else if (!input.path.startsWith('.')) { 75 + if (input.path.startsWith(heyApiRegistryBaseUrl)) { 76 + input.path = input.path.slice(heyApiRegistryBaseUrl.length + 1); 77 + input.path = inputToHeyApiPath(input as Input & { path: string }); 78 + } else { 79 + const parts = input.path.split('/'); 80 + const cleanParts = parts.filter(Boolean); 81 + if (parts.length === 2 && cleanParts.length === 2) { 82 + input.path = inputToHeyApiPath(input as Input & { path: string }); 83 + } 84 + } 85 + } 74 86 } 75 87 76 88 if (
+6 -5
packages/openapi-ts/src/createClient.ts
··· 14 14 import type { WatchValues } from './types/types'; 15 15 import { isLegacyClient, legacyNameFromConfig } from './utils/config'; 16 16 import type { Templates } from './utils/handlebars'; 17 + import { heyApiRegistryBaseUrl } from './utils/input/heyApi'; 17 18 import type { Logger } from './utils/logger'; 18 19 import { postProcessClient } from './utils/postprocess'; 19 20 20 - const isPlatformPath = (path: string) => 21 - path.startsWith('https://get.heyapi.dev'); 21 + const isHeyApiRegistryPath = (path: string) => 22 + path.startsWith(heyApiRegistryBaseUrl); 22 23 // || path.startsWith('http://localhost:4000') 23 24 24 25 export const compileInputPath = (input: Omit<Config['input'], 'watch'>) => { ··· 38 39 39 40 if ( 40 41 input.path && 41 - (typeof input.path !== 'string' || !isPlatformPath(input.path)) 42 + (typeof input.path !== 'string' || !isHeyApiRegistryPath(input.path)) 42 43 ) { 43 44 result.path = input.path; 44 45 return result; ··· 134 135 const baseString = colors.cyan('Generating from'); 135 136 136 137 if (typeof inputPath.path === 'string') { 137 - const baseInput = isPlatformPath(inputPath.path) 138 + const baseInput = isHeyApiRegistryPath(inputPath.path) 138 139 ? `${inputPath.organization ?? ''}/${inputPath.project ?? ''}` 139 140 : inputPath.path; 140 141 console.log(`⏳ ${baseString} ${baseInput}`); 141 - if (isPlatformPath(inputPath.path)) { 142 + if (isHeyApiRegistryPath(inputPath.path)) { 142 143 if (inputPath.branch) { 143 144 console.log( 144 145 `${colors.gray('branch:')} ${colors.green(inputPath.branch)}`,
+5 -4
packages/openapi-ts/src/types/config.d.ts
··· 18 18 */ 19 19 dryRun?: boolean; 20 20 /** 21 - * Path to the OpenAPI specification. This can be either: 22 - * - local file 23 - * - remote path 24 - * - ReadMe API Registry UUID (full and simplified formats) 21 + * Path to the OpenAPI specification. This can be: 22 + * - path 23 + * - URL 24 + * - API registry shorthand 25 25 * 26 26 * Both JSON and YAML file formats are supported. You can also pass the parsed 27 27 * object directly if you're fetching the file yourself. ··· 30 30 */ 31 31 input: 32 32 | `https://get.heyapi.dev/${string}/${string}` 33 + | `${string}/${string}` 33 34 | `readme:@${string}/${string}#${string}` 34 35 | `readme:${string}` 35 36 | (string & {})
+5 -4
packages/openapi-ts/src/types/input.d.ts
··· 36 36 */ 37 37 organization?: string; 38 38 /** 39 - * Path to the OpenAPI specification. This can be either: 40 - * - local file 41 - * - remote path 42 - * - ReadMe API Registry UUID (full and simplified formats) 39 + * Path to the OpenAPI specification. This can be: 40 + * - path 41 + * - URL 42 + * - API registry shorthand 43 43 * 44 44 * Both JSON and YAML file formats are supported. You can also pass the parsed 45 45 * object directly if you're fetching the file yourself. 46 46 */ 47 47 path?: 48 48 | `https://get.heyapi.dev/${string}/${string}` 49 + | `${string}/${string}` 49 50 | `readme:@${string}/${string}#${string}` 50 51 | `readme:${string}` 51 52 | (string & {})
-199
packages/openapi-ts/src/utils/__tests__/readme.test.ts
··· 1 - import { describe, expect, it } from 'vitest'; 2 - 3 - import { 4 - getReadmeApiUrl, 5 - isReadmeInput, 6 - parseReadmeInput, 7 - type ReadmeInput, 8 - transformReadmeInput, 9 - } from '../readme'; 10 - 11 - describe('readme utils', () => { 12 - describe('isReadmeInput', () => { 13 - it('should return true for valid ReadMe formats', () => { 14 - expect(isReadmeInput('readme:abc123')).toBe(true); 15 - expect(isReadmeInput('readme:@org/project#uuid123')).toBe(true); 16 - expect(isReadmeInput('readme:test-uuid-with-hyphens')).toBe(true); 17 - }); 18 - 19 - it('should return false for non-ReadMe inputs', () => { 20 - expect(isReadmeInput('https://example.com')).toBe(false); 21 - expect(isReadmeInput('./local-file.yaml')).toBe(false); 22 - expect(isReadmeInput('random-string')).toBe(false); 23 - expect(isReadmeInput('')).toBe(false); 24 - expect(isReadmeInput('readme')).toBe(false); 25 - expect(isReadmeInput('readmeabc123')).toBe(false); 26 - }); 27 - 28 - it('should handle non-string inputs', () => { 29 - expect(isReadmeInput(123 as any)).toBe(false); 30 - expect(isReadmeInput(null as any)).toBe(false); 31 - expect(isReadmeInput(undefined as any)).toBe(false); 32 - expect(isReadmeInput({} as any)).toBe(false); 33 - }); 34 - }); 35 - 36 - describe('parseReadmeInput', () => { 37 - it('should parse simple UUID format', () => { 38 - const result = parseReadmeInput('readme:abc123'); 39 - expect(result).toEqual({ uuid: 'abc123' }); 40 - }); 41 - 42 - it('should parse UUID with hyphens', () => { 43 - const result = parseReadmeInput('readme:test-uuid-123'); 44 - expect(result).toEqual({ uuid: 'test-uuid-123' }); 45 - }); 46 - 47 - it('should parse full format with organization and project', () => { 48 - const result = parseReadmeInput('readme:@myorg/myproject#uuid123'); 49 - expect(result).toEqual({ 50 - organization: 'myorg', 51 - project: 'myproject', 52 - uuid: 'uuid123', 53 - }); 54 - }); 55 - 56 - it('should parse organization and project with hyphens', () => { 57 - const result = parseReadmeInput('readme:@my-org/my-project#test-uuid'); 58 - expect(result).toEqual({ 59 - organization: 'my-org', 60 - project: 'my-project', 61 - uuid: 'test-uuid', 62 - }); 63 - }); 64 - 65 - it('should throw error for invalid formats', () => { 66 - expect(() => parseReadmeInput('readme:')).toThrow( 67 - 'Invalid ReadMe input format', 68 - ); 69 - expect(() => parseReadmeInput('readme:@org')).toThrow( 70 - 'Invalid ReadMe input format', 71 - ); 72 - expect(() => parseReadmeInput('readme:@org/project')).toThrow( 73 - 'Invalid ReadMe input format', 74 - ); 75 - expect(() => parseReadmeInput('readme:@org/project#')).toThrow( 76 - 'Invalid ReadMe input format', 77 - ); 78 - expect(() => parseReadmeInput('https://example.com')).toThrow( 79 - 'Invalid ReadMe input format', 80 - ); 81 - }); 82 - 83 - it('should throw error for invalid UUID characters', () => { 84 - expect(() => parseReadmeInput('readme:abc@123')).toThrow( 85 - 'Invalid ReadMe input format', 86 - ); 87 - expect(() => parseReadmeInput('readme:abc/123')).toThrow( 88 - 'Invalid ReadMe input format', 89 - ); 90 - expect(() => parseReadmeInput('readme:abc#123')).toThrow( 91 - 'Invalid ReadMe input format', 92 - ); 93 - expect(() => parseReadmeInput('readme:abc 123')).toThrow( 94 - 'Invalid ReadMe input format', 95 - ); 96 - }); 97 - 98 - it('should handle empty UUID', () => { 99 - expect(() => parseReadmeInput('readme:@org/project#')).toThrow( 100 - 'Invalid ReadMe input format', 101 - ); 102 - }); 103 - }); 104 - 105 - describe('getReadmeApiUrl', () => { 106 - it('should generate correct API URL', () => { 107 - expect(getReadmeApiUrl('abc123')).toBe( 108 - 'https://dash.readme.com/api/v1/api-registry/abc123', 109 - ); 110 - expect(getReadmeApiUrl('test-uuid-with-hyphens')).toBe( 111 - 'https://dash.readme.com/api/v1/api-registry/test-uuid-with-hyphens', 112 - ); 113 - }); 114 - }); 115 - 116 - describe('transformReadmeInput', () => { 117 - it('should transform simple UUID format to API URL', () => { 118 - const result = transformReadmeInput('readme:abc123'); 119 - expect(result).toBe('https://dash.readme.com/api/v1/api-registry/abc123'); 120 - }); 121 - 122 - it('should transform full format to API URL', () => { 123 - const result = transformReadmeInput('readme:@myorg/myproject#uuid123'); 124 - expect(result).toBe( 125 - 'https://dash.readme.com/api/v1/api-registry/uuid123', 126 - ); 127 - }); 128 - 129 - it('should throw error for invalid inputs', () => { 130 - expect(() => transformReadmeInput('invalid')).toThrow( 131 - 'Invalid ReadMe input format', 132 - ); 133 - expect(() => transformReadmeInput('readme:')).toThrow( 134 - 'Invalid ReadMe input format', 135 - ); 136 - }); 137 - }); 138 - 139 - describe('integration scenarios', () => { 140 - const validInputs: Array<{ expected: ReadmeInput; input: string }> = [ 141 - { expected: { uuid: 'simple123' }, input: 'readme:simple123' }, 142 - { 143 - expected: { uuid: 'uuid-with-hyphens' }, 144 - input: 'readme:uuid-with-hyphens', 145 - }, 146 - { expected: { uuid: 'UUID123' }, input: 'readme:UUID123' }, 147 - { 148 - expected: { organization: 'org', project: 'proj', uuid: 'uuid' }, 149 - input: 'readme:@org/proj#uuid', 150 - }, 151 - { 152 - expected: { 153 - organization: 'my-org', 154 - project: 'my-project', 155 - uuid: 'my-uuid', 156 - }, 157 - input: 'readme:@my-org/my-project#my-uuid', 158 - }, 159 - ]; 160 - 161 - it.each(validInputs)( 162 - 'should handle $input correctly', 163 - ({ expected, input }) => { 164 - expect(isReadmeInput(input)).toBe(true); 165 - expect(parseReadmeInput(input)).toEqual(expected); 166 - expect(transformReadmeInput(input)).toBe( 167 - `https://dash.readme.com/api/v1/api-registry/${expected.uuid}`, 168 - ); 169 - }, 170 - ); 171 - 172 - const invalidInputs = [ 173 - 'readme:', 174 - 'readme:@', 175 - 'readme:@org', 176 - 'readme:@org/', 177 - 'readme:@org/proj', 178 - 'readme:@org/proj#', 179 - 'readme:uuid with spaces', 180 - 'readme:uuid@invalid', 181 - 'readme:uuid/invalid', 182 - 'readme:uuid#invalid', 183 - 'https://example.com', 184 - './local-file.yaml', 185 - 'random-string', 186 - '', 187 - ]; 188 - 189 - it.each(invalidInputs)('should reject invalid input: %s', (input) => { 190 - if (isReadmeInput(input)) { 191 - expect(() => parseReadmeInput(input)).toThrow(); 192 - } else { 193 - expect(() => parseReadmeInput(input)).toThrow( 194 - 'Invalid ReadMe input format', 195 - ); 196 - } 197 - }); 198 - }); 199 - });
+165
packages/openapi-ts/src/utils/input/__tests__/readme.test.ts
··· 1 + import { describe, expect, it } from 'vitest'; 2 + 3 + import { 4 + getRegistryUrl, 5 + inputToReadmePath, 6 + type Parsed, 7 + parseShorthand, 8 + } from '../readme'; 9 + 10 + describe('readme utils', () => { 11 + describe('parseShorthand', () => { 12 + it('should parse simple UUID format', () => { 13 + const result = parseShorthand('abc123'); 14 + expect(result).toEqual({ uuid: 'abc123' }); 15 + }); 16 + 17 + it('should parse UUID with hyphens', () => { 18 + const result = parseShorthand('test-uuid-123'); 19 + expect(result).toEqual({ uuid: 'test-uuid-123' }); 20 + }); 21 + 22 + it('should parse full format with organization and project', () => { 23 + const result = parseShorthand('@myorg/myproject#uuid123'); 24 + expect(result).toEqual({ 25 + organization: 'myorg', 26 + project: 'myproject', 27 + uuid: 'uuid123', 28 + }); 29 + }); 30 + 31 + it('should parse organization and project with hyphens', () => { 32 + const result = parseShorthand('@my-org/my-project#test-uuid'); 33 + expect(result).toEqual({ 34 + organization: 'my-org', 35 + project: 'my-project', 36 + uuid: 'test-uuid', 37 + }); 38 + }); 39 + 40 + it('should throw error for invalid formats', () => { 41 + expect(() => parseShorthand('')).toThrow( 42 + 'Invalid ReadMe shorthand format', 43 + ); 44 + expect(() => parseShorthand('@org')).toThrow( 45 + 'Invalid ReadMe shorthand format', 46 + ); 47 + expect(() => parseShorthand('@org/project')).toThrow( 48 + 'Invalid ReadMe shorthand format', 49 + ); 50 + expect(() => parseShorthand('@org/project#')).toThrow( 51 + 'Invalid ReadMe shorthand format', 52 + ); 53 + expect(() => parseShorthand('https://example.com')).toThrow( 54 + 'Invalid ReadMe shorthand format', 55 + ); 56 + }); 57 + 58 + it('should throw error for invalid UUID characters', () => { 59 + expect(() => parseShorthand('abc@123')).toThrow( 60 + 'Invalid ReadMe shorthand format', 61 + ); 62 + expect(() => parseShorthand('abc/123')).toThrow( 63 + 'Invalid ReadMe shorthand format', 64 + ); 65 + expect(() => parseShorthand('abc#123')).toThrow( 66 + 'Invalid ReadMe shorthand format', 67 + ); 68 + expect(() => parseShorthand('abc 123')).toThrow( 69 + 'Invalid ReadMe shorthand format', 70 + ); 71 + }); 72 + 73 + it('should handle empty UUID', () => { 74 + expect(() => parseShorthand('@org/project#')).toThrow( 75 + 'Invalid ReadMe shorthand format', 76 + ); 77 + }); 78 + }); 79 + 80 + describe('getRegistryUrl', () => { 81 + it('should generate correct URL', () => { 82 + expect(getRegistryUrl('abc123')).toBe( 83 + 'https://dash.readme.com/api/v1/api-registry/abc123', 84 + ); 85 + expect(getRegistryUrl('test-uuid-with-hyphens')).toBe( 86 + 'https://dash.readme.com/api/v1/api-registry/test-uuid-with-hyphens', 87 + ); 88 + }); 89 + }); 90 + 91 + describe('inputToReadmePath', () => { 92 + it('should transform simple UUID format to API URL', () => { 93 + const result = inputToReadmePath('readme:abc123'); 94 + expect(result).toBe('https://dash.readme.com/api/v1/api-registry/abc123'); 95 + }); 96 + 97 + it('should transform full format to API URL', () => { 98 + const result = inputToReadmePath('readme:@myorg/myproject#uuid123'); 99 + expect(result).toBe( 100 + 'https://dash.readme.com/api/v1/api-registry/uuid123', 101 + ); 102 + }); 103 + 104 + it('should throw error for invalid inputs', () => { 105 + expect(() => inputToReadmePath('invalid')).toThrow( 106 + 'Invalid ReadMe shorthand format', 107 + ); 108 + expect(() => inputToReadmePath('')).toThrow( 109 + 'Invalid ReadMe shorthand format', 110 + ); 111 + }); 112 + }); 113 + 114 + describe('integration scenarios', () => { 115 + const validInputs: ReadonlyArray<{ expected: Parsed; input: string }> = [ 116 + { expected: { uuid: 'simple123' }, input: 'simple123' }, 117 + { 118 + expected: { uuid: 'uuid-with-hyphens' }, 119 + input: 'uuid-with-hyphens', 120 + }, 121 + { expected: { uuid: 'UUID123' }, input: 'UUID123' }, 122 + { 123 + expected: { organization: 'org', project: 'proj', uuid: 'uuid' }, 124 + input: '@org/proj#uuid', 125 + }, 126 + { 127 + expected: { 128 + organization: 'my-org', 129 + project: 'my-project', 130 + uuid: 'my-uuid', 131 + }, 132 + input: '@my-org/my-project#my-uuid', 133 + }, 134 + ]; 135 + 136 + it.each(validInputs)( 137 + 'should handle $input correctly', 138 + ({ expected, input }) => { 139 + expect(parseShorthand(input)).toEqual(expected); 140 + expect(inputToReadmePath(`readme:${input}`)).toBe( 141 + `https://dash.readme.com/api/v1/api-registry/${expected.uuid}`, 142 + ); 143 + }, 144 + ); 145 + 146 + const invalidInputs = [ 147 + '', 148 + '@', 149 + '@org', 150 + '@org/', 151 + '@org/proj', 152 + '@org/proj#', 153 + 'uuid with spaces', 154 + 'uuid@invalid', 155 + 'uuid/invalid', 156 + 'uuid#invalid', 157 + 'https://example.com', 158 + './local-file.yaml', 159 + ]; 160 + 161 + it.each(invalidInputs)('should reject invalid input: %s', (input) => { 162 + expect(() => parseShorthand(input)).toThrow(); 163 + }); 164 + }); 165 + });
+95
packages/openapi-ts/src/utils/input/heyApi.ts
··· 1 + // Regular expression to match Hey API Registry input formats: 2 + 3 + import type { Input } from '../../types/input'; 4 + 5 + // - {organization}/{project}?{queryParams} 6 + const registryRegExp = /^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/; 7 + 8 + export const heyApiRegistryBaseUrl = 'https://get.heyapi.dev'; 9 + 10 + /** 11 + * Generates the Hey API Registry URL for a given UUID. 12 + * 13 + * @param organization - Organization slug 14 + * @param project - Project slug 15 + * @param queryParams - Optional query parameters 16 + * @returns The full API registry URL 17 + */ 18 + export const getRegistryUrl = ( 19 + organization: string, 20 + project: string, 21 + queryParams?: string, 22 + ): string => 23 + `${heyApiRegistryBaseUrl}/${organization}/${project}${queryParams ? `?${queryParams}` : ''}`; 24 + 25 + export interface Parsed { 26 + organization: string; 27 + project: string; 28 + queryParams?: string; 29 + } 30 + 31 + /** 32 + * Parses a Hey API input string and extracts components. 33 + * 34 + * @param input - Hey API configuration input 35 + * @returns Parsed Hey API input components 36 + * @throws Error if the input format is invalid 37 + */ 38 + export const parseShorthand = ( 39 + input: Omit<Input, 'path'> & { 40 + path: string; 41 + }, 42 + ): Parsed => { 43 + let organization = input.organization; 44 + let project = input.project; 45 + let queryParams: string | undefined; 46 + 47 + if (input.path) { 48 + const match = input.path.match(registryRegExp); 49 + 50 + if (!match) { 51 + throw new Error( 52 + `Invalid Hey API shorthand format. Expected "organization/project?queryParams" or "organization/project", received: ${input.path}`, 53 + ); 54 + } 55 + 56 + organization = match[1]; 57 + project = match[2]; 58 + queryParams = match[3]; 59 + } 60 + 61 + if (!organization) { 62 + throw new Error('The Hey API organization cannot be empty.'); 63 + } 64 + 65 + if (!project) { 66 + throw new Error('The Hey API organization cannot be empty.'); 67 + } 68 + 69 + const result: Parsed = { 70 + organization, 71 + project, 72 + queryParams, 73 + }; 74 + 75 + return result; 76 + }; 77 + 78 + /** 79 + * Transforms a Hey API shorthand string to the corresponding API URL. 80 + * 81 + * @param input - Hey API configuration input 82 + * @returns The Hey API Registry URL 83 + */ 84 + export const inputToHeyApiPath = ( 85 + input: Omit<Input, 'path'> & { 86 + path: string; 87 + }, 88 + ): string => { 89 + const parsed = parseShorthand(input); 90 + return getRegistryUrl( 91 + parsed.organization, 92 + parsed.project, 93 + parsed.queryParams, 94 + ); 95 + };
+64
packages/openapi-ts/src/utils/input/readme.ts
··· 1 + // Regular expression to match ReadMe API Registry input formats: 2 + // - @{organization}/{project}#{uuid} 3 + // - {uuid} 4 + const registryRegExp = /^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/; 5 + 6 + /** 7 + * Generates the Hey API Registry URL for a given UUID. 8 + * 9 + * @param uuid - The Hey API Registry UUID 10 + * @returns The full API registry URL 11 + */ 12 + export const getRegistryUrl = (uuid: string): string => 13 + `https://dash.readme.com/api/v1/api-registry/${uuid}`; 14 + 15 + export interface Parsed { 16 + organization?: string; 17 + project?: string; 18 + uuid: string; 19 + } 20 + 21 + const namespace = 'readme'; 22 + 23 + /** 24 + * Parses a ReadMe input string and extracts components. 25 + * 26 + * @param shorthand - ReadMe format string (@org/project#uuid or uuid) 27 + * @returns Parsed ReadMe input components 28 + * @throws Error if the input format is invalid 29 + */ 30 + export const parseShorthand = (shorthand: string): Parsed => { 31 + const match = shorthand.match(registryRegExp); 32 + 33 + if (!match) { 34 + throw new Error( 35 + `Invalid ReadMe shorthand format. Expected "${namespace}:@organization/project#uuid" or "${namespace}:uuid", received: ${namespace}:${shorthand}`, 36 + ); 37 + } 38 + 39 + const [, , organization, project, uuid] = match; 40 + 41 + if (!uuid) { 42 + throw new Error('The ReadMe shorthand UUID cannot be empty.'); 43 + } 44 + 45 + const result: Parsed = { 46 + organization, 47 + project, 48 + uuid, 49 + }; 50 + 51 + return result; 52 + }; 53 + 54 + /** 55 + * Transforms a ReadMe shorthand string to the corresponding API URL. 56 + * 57 + * @param input - ReadMe format string 58 + * @returns The ReadMe API Registry URL 59 + */ 60 + export const inputToReadmePath = (input: string): string => { 61 + const shorthand = input.slice(`${namespace}:`.length); 62 + const parsed = parseShorthand(shorthand); 63 + return getRegistryUrl(parsed.uuid); 64 + };
-73
packages/openapi-ts/src/utils/readme.ts
··· 1 - // Regular expression to match ReadMe input formats: 2 - // readme:@organization/project#uuid or readme:uuid 3 - const readmeInputRegExp = /^readme:(?:@([\w-]+)\/([\w-]+)#)?([\w-]+)$/; 4 - 5 - export interface ReadmeInput { 6 - organization?: string; 7 - project?: string; 8 - uuid: string; 9 - } 10 - 11 - /** 12 - * Checks if the input string is a ReadMe format 13 - * @param input - The input string to check 14 - * @returns true if the input matches ReadMe format patterns 15 - */ 16 - export const isReadmeInput = (input: string): boolean => 17 - typeof input === 'string' && input.startsWith('readme:'); 18 - 19 - /** 20 - * Parses a ReadMe input string and extracts components 21 - * @param input - ReadMe format string (readme:@org/project#uuid or readme:uuid) 22 - * @returns Parsed ReadMe input components 23 - * @throws Error if the input format is invalid 24 - */ 25 - export const parseReadmeInput = (input: string): ReadmeInput => { 26 - if (!isReadmeInput(input)) { 27 - throw new Error( 28 - `Invalid ReadMe input format. Expected "readme:@organization/project#uuid" or "readme:uuid", received: ${input}`, 29 - ); 30 - } 31 - 32 - const match = input.match(readmeInputRegExp); 33 - 34 - if (!match) { 35 - throw new Error( 36 - `Invalid ReadMe input format. Expected "readme:@organization/project#uuid" or "readme:uuid", received: ${input}`, 37 - ); 38 - } 39 - 40 - const [, organization, project, uuid] = match; 41 - 42 - // Validate UUID format (basic validation for alphanumeric + hyphens) 43 - if (!uuid || !/^[\w-]+$/.test(uuid)) { 44 - throw new Error(`Invalid UUID format: ${uuid}`); 45 - } 46 - 47 - const result: ReadmeInput = { uuid }; 48 - 49 - if (organization && project) { 50 - result.organization = organization; 51 - result.project = project; 52 - } 53 - 54 - return result; 55 - }; 56 - 57 - /** 58 - * Generates the ReadMe API Registry URL for a given UUID 59 - * @param uuid - The ReadMe API Registry UUID 60 - * @returns The full API URL 61 - */ 62 - export const getReadmeApiUrl = (uuid: string): string => 63 - `https://dash.readme.com/api/v1/api-registry/${uuid}`; 64 - 65 - /** 66 - * Transforms a ReadMe input string to the corresponding API URL 67 - * @param input - ReadMe format string 68 - * @returns The ReadMe API Registry URL 69 - */ 70 - export const transformReadmeInput = (input: string): string => { 71 - const parsed = parseReadmeInput(input); 72 - return getReadmeApiUrl(parsed.uuid); 73 - };