@povio/openapi-codegen-cli 3.0.0-rc.9 → 3.0.1-rc.1
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 +41 -0
- package/dist/acl.d.mts +1 -1
- package/dist/{config-C1ME3Ay4.d.mts → config-CrZa_Jbm.d.mts} +1 -1
- package/dist/{generate.runner-DSZ2ivlU.mjs → generate.runner-DnUDkoAZ.mjs} +1 -1
- package/dist/{generateCodeFromOpenAPIDoc-NA2XZmIv.mjs → generateCodeFromOpenAPIDoc-CbQ9gQss.mjs} +307 -209
- package/dist/generator.d.mts +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/index.d.mts +6 -3
- package/dist/index.mjs +14 -3
- package/dist/metro.d.mts +32 -0
- package/dist/metro.mjs +86 -0
- package/dist/openapi-codegen.runner-Bht20Dfx.mjs +42 -0
- package/dist/sh.mjs +3 -3
- package/dist/vite.d.mts +7 -4
- package/dist/vite.mjs +9 -23
- package/dist/zod.d.mts +1 -1
- package/package.json +6 -2
- /package/dist/{error-handling-B4aYKmyL.d.mts → error-handling-oM5YJYYH.d.mts} +0 -0
- /package/dist/{options-BPAjzilp.d.mts → options-BZOw7Hx4.d.mts} +0 -0
package/README.md
CHANGED
|
@@ -215,6 +215,16 @@ import { ErrorHandler, OpenApiQueryConfig } from "@povio/openapi-codegen-cli";
|
|
|
215
215
|
</OpenApiQueryConfig.Provider>;
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
+
### Runtime response validation
|
|
219
|
+
|
|
220
|
+
Use `OpenApiQueryConfig.Provider` to allow generated GET query hooks to return invalid response data while still logging the response Zod error to the console. Non-GET requests still throw on invalid response data.
|
|
221
|
+
|
|
222
|
+
```tsx
|
|
223
|
+
<OpenApiQueryConfig.Provider allowInvalidResponseData={import.meta.env.DEV}>
|
|
224
|
+
<App />
|
|
225
|
+
</OpenApiQueryConfig.Provider>
|
|
226
|
+
```
|
|
227
|
+
|
|
218
228
|
### OpenApiWorkspaceContext (Path + ACL defaults)
|
|
219
229
|
|
|
220
230
|
Set `workspaceContext` to a list of param names in codegen config (or pass `--workspaceContext officeId,projectId`) and wrap your app subtree with `OpenApiWorkspaceContext.Provider` if generated hooks frequently repeat workspace-scoped params.
|
|
@@ -277,6 +287,37 @@ export default defineConfig({
|
|
|
277
287
|
The plugin runs on both `vite serve` and `vite build`, and watches local OpenAPI files in dev mode.
|
|
278
288
|
If you provide `formatGeneratedFile`, the plugin formats each generated file in memory before comparing and writing it, which helps avoid unnecessary HMR when the formatted output is unchanged.
|
|
279
289
|
|
|
290
|
+
### Metro Plugin
|
|
291
|
+
|
|
292
|
+
You can run codegen directly from React Native Metro config:
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
import { fileURLToPath } from "url";
|
|
296
|
+
import { getDefaultConfig } from "@react-native/metro-config";
|
|
297
|
+
import { withOpenApiCodegen } from "@povio/openapi-codegen-cli/metro";
|
|
298
|
+
|
|
299
|
+
const root = fileURLToPath(new URL("./", import.meta.url));
|
|
300
|
+
const config = getDefaultConfig(root);
|
|
301
|
+
|
|
302
|
+
export default withOpenApiCodegen(
|
|
303
|
+
config,
|
|
304
|
+
{
|
|
305
|
+
input: "./openapi.yaml",
|
|
306
|
+
output: "./src/data",
|
|
307
|
+
inlineEndpoints: true,
|
|
308
|
+
incremental: true,
|
|
309
|
+
formatGeneratedFile: async ({ fileName, content }) => {
|
|
310
|
+
void fileName;
|
|
311
|
+
return content;
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
{ root },
|
|
315
|
+
);
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
The Metro wrapper runs generation when the config is loaded, waits for it before Metro transforms or serves the first request, and watches local OpenAPI files while the dev server is running.
|
|
319
|
+
If you provide `formatGeneratedFile`, it behaves the same way as the Vite plugin.
|
|
320
|
+
|
|
280
321
|
### Enums
|
|
281
322
|
|
|
282
323
|
If you're using Enums in your backend DTOs with `@Expose()` and `@IsEnum`, they may still not appear correctly in the OpenAPI schema unless you also provide both `enum` **and** `enumName` to `@ApiProperty`.
|
package/dist/acl.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ErrorHandler } from "./error-handling-
|
|
1
|
+
import { a as ErrorHandler } from "./error-handling-oM5YJYYH.mjs";
|
|
2
2
|
import * as react from "react";
|
|
3
3
|
import { PropsWithChildren } from "react";
|
|
4
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as Profiler, h as deepMerge, i as writeGenerateFileData, p as DEFAULT_GENERATE_OPTIONS, r as removeStaleGeneratedFiles, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-
|
|
1
|
+
import { S as Profiler, h as deepMerge, i as writeGenerateFileData, p as DEFAULT_GENERATE_OPTIONS, r as removeStaleGeneratedFiles, t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-CbQ9gQss.mjs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
4
4
|
|