Skip to content

Commit

Permalink
chore: fix zod extending with openapi not triggering at appropriate time
Browse files Browse the repository at this point in the history
  • Loading branch information
brunotot committed Aug 29, 2024
1 parent d213bc9 commit 489a597
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/shared/src/config/Contract.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type AppRouter } from "@ts-rest/core";
import { type generateOpenApi } from "@ts-rest/open-api";
import { z } from "zod";
import { type TODO } from "./Types.config";
import { z } from "./Zod.config";

export type OperationMapper = NonNullable<Parameters<typeof generateOpenApi>[2]>["operationMapper"];

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/config/Entity.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { ObjectId } from "./Types.config";
import { z } from "./Zod.config";

export const BASE_ENTITY_SCHEMA = {
_id: z.instanceof(ObjectId).optional(),
Expand Down
5 changes: 5 additions & 0 deletions packages/shared/src/config/Zod.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import z from "zod";
import { extendZodWithOpenApi } from "@anatine/zod-openapi";
extendZodWithOpenApi(z);

export { z };
4 changes: 4 additions & 0 deletions packages/shared/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import z from "zod";
import { extendZodWithOpenApi } from "@anatine/zod-openapi";
extendZodWithOpenApi(z);

export * from "./Contract.config";
export * from "./Entity.config";
export * from "./ResponseError.config";
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/domain/ErrorLog/ErrorLog.domain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Entity } from "../../config/Entity.config";
import z from "zod";
import { z } from "../../config/Zod.config";

/** @hidden */
export const ErrorLog = Entity("ErrorLog", {
Expand Down
5 changes: 2 additions & 3 deletions packages/shared/src/domain/User/User.domain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Role } from "../../config";
import { Entity } from "../../config/Entity.config";
import z from "zod";
import { Role, Entity } from "../../config";
import { z } from "../../config/Zod.config";

/** @hidden */
export const User = Entity("User", {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/domain/User/User.typedef.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z } from "zod";
import { z } from "../../config/Zod.config";
import { User } from "./User.domain";

/** @hidden */
Expand Down
4 changes: 0 additions & 4 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
* @packageDocumentation This shared package supplies backend and frontend with a set of config, models, types, utils and web components.
*/

import z from "zod";
import { extendZodWithOpenApi } from "@anatine/zod-openapi";
extendZodWithOpenApi(z);

export * from "./config";
export * from "./domain";
export * from "./errors";
Expand Down

0 comments on commit 489a597

Please sign in to comment.