@sdk-it/typescript 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@ This package transforms OpenAPI specifications into fully-typed TypeScript clien
12
12
  npm install @sdk-it/typescript
13
13
  ```
14
14
 
15
- ## Usage Examples
15
+ ## Usage
16
16
 
17
17
  ### Basic SDK Generation
18
18
 
@@ -43,3 +43,23 @@ await generate(spec, {
43
43
  name: 'PetStore',
44
44
  });
45
45
  ```
46
+
47
+ ### Format Generated Code
48
+
49
+ You can format the generated code using the `formatCode` option. This is especially useful if you include the generated code in source control.
50
+
51
+ ```typescript
52
+ import { generate } from '@sdk-it/typescript';
53
+
54
+ const spec = await fetch('https://petstore.swagger.io/v2/swagger.json').then(
55
+ (res) => res.json(),
56
+ );
57
+
58
+ // Format generated code using Prettier
59
+ await generate(spec, {
60
+ output: join(process.cwd(), 'node_modules/.sdk-it/client'),
61
+ formatCode: ({ output, env }) => {
62
+ execFile('prettier', [output, '--write'], { env: env });
63
+ },
64
+ });
65
+ ```