Skip to content

Commit 924e206

Browse files
chore: update test snapshots
1 parent bc8e1a4 commit 924e206

File tree

264 files changed

+23403
-28701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

264 files changed

+23403
-28701
lines changed

.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
**/templates
44
**/dist
55
**/.vitepress
6+
**/test/e2e
67

78
**/CHANGELOG.md
9+
pnpm-lock.yaml

docs/openapi-ts/configuration.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ description: Configure openapi-ts.
1010
::: code-group
1111

1212
```js [openapi-ts.config.ts]
13-
import { defineConfig } from '@hey-api/openapi-ts'
13+
import { defineConfig } from '@hey-api/openapi-ts';
1414

1515
export default defineConfig({
1616
input: 'path/to/openapi.json',
17-
output: 'src/client'
18-
})
17+
output: 'src/client',
18+
});
1919
```
2020

2121
```js [openapi-ts.config.cjs]
2222
/** @type {import('@hey-api/openapi-ts').UserConfig} */
2323
module.exports = {
2424
input: 'path/to/openapi.json',
25-
output: 'src/client'
26-
}
25+
output: 'src/client',
26+
};
2727
```
2828

2929
```js [openapi-ts.config.mjs]
3030
/** @type {import('@hey-api/openapi-ts').UserConfig} */
3131
export default {
3232
input: 'path/to/openapi.json',
33-
output: 'src/client'
34-
}
33+
output: 'src/client',
34+
};
3535
```
3636

3737
:::
@@ -165,12 +165,12 @@ export default {
165165
By default, `openapi-ts` exports schemas from your OpenAPI specification as plain JavaScript objects. A great use case for schemas is client-side form input validation.
166166

167167
```ts
168-
import { $Schema } from 'client/schemas'
168+
import { $Schema } from 'client/schemas';
169169

170-
const maxInputLength = $Schema.properties.text.maxLength
170+
const maxInputLength = $Schema.properties.text.maxLength;
171171

172172
if (userInput.length > maxInputLength) {
173-
throw new Error(`String length cannot exceed ${maxInputLength} characters!`)
173+
throw new Error(`String length cannot exceed ${maxInputLength} characters!`);
174174
}
175175
```
176176

docs/openapi-ts/get-started.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ If you want to use `openapi-ts` with CLI, add a script to your `package.json` fi
6060
You can also generate your client programmatically by importing `openapi-ts` in a `.ts` file.
6161

6262
```ts
63-
import { createClient } from '@hey-api/openapi-ts'
63+
import { createClient } from '@hey-api/openapi-ts';
6464

6565
createClient({
6666
input: 'path/to/openapi.json',
67-
output: 'src/client'
68-
})
67+
output: 'src/client',
68+
});
6969
```
7070

7171
::: warning

docs/openapi-ts/interceptors.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ Interceptors (middleware) can be used to modify requests before they're sent or
1010
::: code-group
1111

1212
```ts [use]
13-
OpenAPI.interceptors.request.use(request => {
14-
doSomethingWithRequest(request)
15-
return request // <-- must return request
16-
})
13+
OpenAPI.interceptors.request.use((request) => {
14+
doSomethingWithRequest(request);
15+
return request; // <-- must return request
16+
});
1717
```
1818

1919
```ts [eject]
20-
OpenAPI.interceptors.request.eject(request => {
21-
doSomethingWithRequest(request)
22-
return request // <-- must return request
23-
})
20+
OpenAPI.interceptors.request.eject((request) => {
21+
doSomethingWithRequest(request);
22+
return request; // <-- must return request
23+
});
2424
```
2525

2626
:::
@@ -30,17 +30,17 @@ and an example response interceptor
3030
::: code-group
3131

3232
```ts [use]
33-
OpenAPI.interceptors.response.use(async response => {
34-
await doSomethingWithResponse(response) // async
35-
return response // <-- must return response
36-
})
33+
OpenAPI.interceptors.response.use(async (response) => {
34+
await doSomethingWithResponse(response); // async
35+
return response; // <-- must return response
36+
});
3737
```
3838

3939
```ts [eject]
40-
OpenAPI.interceptors.response.eject(async response => {
41-
await doSomethingWithResponse(response) // async
42-
return response // <-- must return response
43-
})
40+
OpenAPI.interceptors.response.eject(async (response) => {
41+
await doSomethingWithResponse(response); // async
42+
return response; // <-- must return response
43+
});
4444
```
4545

4646
:::

docs/openapi-ts/migrating.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ Enums are now re-exported from the main `index.ts` file.
9292
Enums are now exported from a separate file. If you use imports from `models.ts`, you can change them to `enums.gen.ts`.
9393

9494
```js
95-
import { Enum } from 'client/models' // [!code --]
96-
import { Enum } from 'client/enums.gen' // [!code ++]
95+
import { Enum } from 'client/models'; // [!code --]
96+
import { Enum } from 'client/enums.gen'; // [!code ++]
9797
```
9898

9999
### Renamed `models.ts` file
@@ -110,17 +110,17 @@ import type { Model } from 'client/models.gen' // [!code ++]
110110
`schemas.ts` is now called `schemas.gen.ts`. If you use imports from `schemas.ts`, you should be able to easily find and replace all instances.
111111

112112
```js
113-
import { $Schema } from 'client/schemas' // [!code --]
114-
import { $Schema } from 'client/schemas.gen' // [!code ++]
113+
import { $Schema } from 'client/schemas'; // [!code --]
114+
import { $Schema } from 'client/schemas.gen'; // [!code ++]
115115
```
116116

117117
### Renamed `services.ts` file
118118

119119
`services.ts` is now called `services.gen.ts`. If you use imports from `services.ts`, you should be able to easily find and replace all instances.
120120

121121
```js
122-
import { DefaultService } from 'client/services' // [!code --]
123-
import { DefaultService } from 'client/services.gen' // [!code ++]
122+
import { DefaultService } from 'client/services'; // [!code --]
123+
import { DefaultService } from 'client/services.gen'; // [!code ++]
124124
```
125125

126126
### Deprecated exports from `index.ts`
@@ -194,9 +194,9 @@ Schemas are now exported from a single file. If you used imports from individual
194194
By default, generated clients will use a single object argument to pass values to API calls. This is a significant change from the previous default of unspecified array of arguments. If migrating your application in one go isn't feasible, we recommend deprecating your old client and generating a new client.
195195

196196
```ts
197-
import { DefaultService } from 'client/services' // <-- old client with array arguments
197+
import { DefaultService } from 'client/services'; // <-- old client with array arguments
198198

199-
import { DefaultService } from 'client_v2/services' // <-- new client with options argument
199+
import { DefaultService } from 'client_v2/services'; // <-- new client with options argument
200200
```
201201

202202
This way, you can gradually switch over to the new syntax as you update parts of your code. Once you've removed all instances of `client` imports, you can safely delete the old `client` folder and find and replace all `client_v2` calls to `client`.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
"@changesets/cli": "2.27.1",
3535
"@svitejs/changesets-changelog-github-compact": "1.1.0",
3636
"prettier": "3.2.5"
37-
}
37+
},
38+
"packageManager": "pnpm@8.15.7+sha256.50783dd0fa303852de2dd1557cd4b9f07cb5b018154a6e76d0f40635d6cee019"
3839
}

packages/openapi-ts/bin/index.cjs

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
#!/usr/bin/env node
22

3-
'use strict'
3+
'use strict';
44

5-
const { writeFileSync } = require('fs')
6-
const { resolve } = require('path')
5+
const { writeFileSync } = require('fs');
6+
const { resolve } = require('path');
77

8-
const { program } = require('commander')
9-
const pkg = require('../package.json')
8+
const { program } = require('commander');
9+
const pkg = require('../package.json');
1010

1111
const params = program
1212
.name(Object.keys(pkg.bin)[0])
1313
.usage('[options]')
1414
.version(pkg.version)
1515
.option(
1616
'-i, --input <value>',
17-
'OpenAPI specification (path, url, or string content)'
17+
'OpenAPI specification (path, url, or string content)',
1818
)
1919
.option('-o, --output <value>', 'Output directory')
2020
.option(
2121
'-c, --client <value>',
22-
'HTTP client to generate [angular, axios, fetch, node, xhr]'
22+
'HTTP client to generate [angular, axios, fetch, node, xhr]',
2323
)
2424
.option('-d, --debug', 'Run in debug mode?')
2525
.option(
2626
'--base [value]',
27-
'Manually set base in OpenAPI config instead of inferring from server value'
27+
'Manually set base in OpenAPI config instead of inferring from server value',
2828
)
2929
.option('--dry-run [value]', 'Skip writing files to disk?')
3030
.option('--enums <value>', 'Export enum definitions (javascript, typescript)')
@@ -39,45 +39,45 @@ const params = program
3939
.option('--schemas [value]', 'Write schemas to disk')
4040
.option(
4141
'--serviceResponse [value]',
42-
'Define shape of returned value from service calls'
42+
'Define shape of returned value from service calls',
4343
)
4444
.option('--types [value]', 'Write types to disk')
4545
.option(
4646
'--useDateType [value]',
47-
'Output Date instead of string for the format "date-time" in the models'
47+
'Output Date instead of string for the format "date-time" in the models',
4848
)
4949
.option('--useOptions [value]', 'Use options instead of arguments')
5050
.parse(process.argv)
51-
.opts()
51+
.opts();
5252

53-
const stringToBoolean = value => {
53+
const stringToBoolean = (value) => {
5454
if (value === 'true') {
55-
return true
55+
return true;
5656
}
5757
if (value === 'false') {
58-
return false
58+
return false;
5959
}
60-
return value
61-
}
60+
return value;
61+
};
6262

6363
const processParams = (obj, booleanKeys) => {
6464
for (const key of booleanKeys) {
65-
const value = obj[key]
65+
const value = obj[key];
6666
if (typeof value === 'string') {
67-
const parsedValue = stringToBoolean(value)
68-
delete obj[key]
69-
obj[key] = parsedValue
67+
const parsedValue = stringToBoolean(value);
68+
delete obj[key];
69+
obj[key] = parsedValue;
7070
}
7171
}
72-
return obj
73-
}
72+
return obj;
73+
};
7474

7575
async function start() {
76-
let userConfig
76+
let userConfig;
7777
try {
7878
const { createClient } = require(
79-
resolve(__dirname, '../dist/node/index.cjs')
80-
)
79+
resolve(__dirname, '../dist/node/index.cjs'),
80+
);
8181
userConfig = processParams(params, [
8282
'dryRun',
8383
'exportCore',
@@ -88,20 +88,20 @@ async function start() {
8888
'schemas',
8989
'types',
9090
'useDateType',
91-
'useOptions'
92-
])
93-
await createClient(userConfig)
94-
process.exit(0)
91+
'useOptions',
92+
]);
93+
await createClient(userConfig);
94+
process.exit(0);
9595
} catch (error) {
9696
if (!userConfig.dryRun) {
97-
const logName = `openapi-ts-error-${Date.now()}.log`
98-
const logPath = resolve(process.cwd(), logName)
99-
writeFileSync(logPath, `${error.message}\n${error.stack}`)
100-
console.error(`🔥 Unexpected error occurred. Log saved to ${logPath}`)
97+
const logName = `openapi-ts-error-${Date.now()}.log`;
98+
const logPath = resolve(process.cwd(), logName);
99+
writeFileSync(logPath, `${error.message}\n${error.stack}`);
100+
console.error(`🔥 Unexpected error occurred. Log saved to ${logPath}`);
101101
}
102-
console.error(`🔥 Unexpected error occurred. ${error.message}`)
103-
process.exit(1)
102+
console.error(`🔥 Unexpected error occurred. ${error.message}`);
103+
process.exit(1);
104104
}
105105
}
106106

107-
start()
107+
start();

packages/openapi-ts/eslint.config.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import eslint from '@eslint/js'
2-
import eslintConfigPrettier from 'eslint-config-prettier'
3-
import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort'
4-
import eslintPluginSortKeysFix from 'eslint-plugin-sort-keys-fix'
5-
import globals from 'globals'
6-
import tseslint from 'typescript-eslint'
1+
import eslint from '@eslint/js';
2+
import eslintConfigPrettier from 'eslint-config-prettier';
3+
import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort';
4+
import eslintPluginSortKeysFix from 'eslint-plugin-sort-keys-fix';
5+
import globals from 'globals';
6+
import tseslint from 'typescript-eslint';
77

88
export default tseslint.config(
99
eslint.configs.recommended,
@@ -12,12 +12,12 @@ export default tseslint.config(
1212
languageOptions: {
1313
ecmaVersion: 'latest',
1414
globals: {
15-
...globals.node
16-
}
15+
...globals.node,
16+
},
1717
},
1818
plugins: {
1919
'simple-import-sort': eslintPluginSimpleImportSort,
20-
'sort-keys-fix': eslintPluginSortKeysFix
20+
'sort-keys-fix': eslintPluginSortKeysFix,
2121
},
2222
rules: {
2323
'@typescript-eslint/ban-ts-comment': 'off',
@@ -35,8 +35,8 @@ export default tseslint.config(
3535
'simple-import-sort/exports': 'error',
3636
'simple-import-sort/imports': 'error',
3737
'sort-imports': 'off',
38-
'sort-keys-fix/sort-keys-fix': 'warn'
39-
}
38+
'sort-keys-fix/sort-keys-fix': 'warn',
39+
},
4040
},
4141
eslintConfigPrettier,
4242
{
@@ -45,7 +45,7 @@ export default tseslint.config(
4545
'**/node_modules/',
4646
'temp/',
4747
'**/test/e2e/generated/',
48-
'**/test/generated/'
49-
]
50-
}
51-
)
48+
'**/test/generated/',
49+
],
50+
},
51+
);

0 commit comments

Comments
 (0)