diff --git a/package.json b/package.json index 5f6bca4..142462c 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,6 @@ "entryPoint": "src/index.ts", "template": "oss-npm-package", "type": "package", - "version": "9.0.0-main-20240928013837" + "version": "9.1.0" } } diff --git a/src/create/schema/index.ts b/src/create/schema/index.ts index 7fb8b90..5f69f07 100644 --- a/src/create/schema/index.ts +++ b/src/create/schema/index.ts @@ -1,5 +1,6 @@ import type { ZodType, ZodTypeDef } from 'zod'; +import { currentSymbol, previousSymbol } from '../../extendZodTypes'; import type { oas30, oas31 } from '../../openapi3-ts/dist'; import { type ComponentsObject, @@ -13,7 +14,6 @@ import { enhanceWithMetadata } from './metadata'; import { createSchemaSwitch } from './parsers'; import { verifyEffects } from './parsers/transform'; import type { CreateSchemaOptions } from './single'; -import { currentSymbol, previousSymbol } from '../../extendZodTypes'; export type LazyMap = Map; @@ -222,17 +222,21 @@ export const createSchemaOrRef = < } const previous = zodSchema._def.zodOpenApi?.[previousSymbol] - ? (createSchemaOrRef(zodSchema._def.zodOpenApi[previousSymbol], state, true) as - | RefObject - | undefined) + ? (createSchemaOrRef( + zodSchema._def.zodOpenApi[previousSymbol], + state, + true, + ) as RefObject | undefined) : undefined; const current = zodSchema._def.zodOpenApi?.[currentSymbol] && zodSchema._def.zodOpenApi[currentSymbol] !== zodSchema - ? (createSchemaOrRef(zodSchema._def.zodOpenApi[currentSymbol], state, true) as - | RefObject - | undefined) + ? (createSchemaOrRef( + zodSchema._def.zodOpenApi[currentSymbol], + state, + true, + ) as RefObject | undefined) : undefined; const ref = zodSchema._def.zodOpenApi?.openapi?.ref ?? component?.ref; diff --git a/src/create/schema/metadata.test.ts b/src/create/schema/metadata.test.ts index b83bacb..c61860c 100644 --- a/src/create/schema/metadata.test.ts +++ b/src/create/schema/metadata.test.ts @@ -937,6 +937,8 @@ describe('enhanceWithMetadata', () => { it('does not fail JSON serialization', () => { const FooSchema = z.string().openapi({ ref: 'foo' }); - expect(()=>{JSON.stringify(FooSchema)}).not.toThrow(); + expect(() => { + JSON.stringify(FooSchema); + }).not.toThrow(); }); }); diff --git a/src/entries/extend.ts b/src/entries/extend.ts index fea7d7e..ad509e9 100644 --- a/src/entries/extend.ts +++ b/src/entries/extend.ts @@ -4,5 +4,4 @@ import { extendZodWithOpenApi } from '../extendZod'; extendZodWithOpenApi(z); -// eslint-disable-next-line @typescript-eslint/consistent-type-exports export * from '../extendZodTypes'; // compatibility with < TS 5.0 as the export type * syntax is not supported diff --git a/src/extendZod.test.ts b/src/extendZod.test.ts index b9d8492..831ee36 100644 --- a/src/extendZod.test.ts +++ b/src/extendZod.test.ts @@ -23,7 +23,8 @@ describe('extendZodWithOpenApi', () => { expect(a._def.zodOpenApi?.openapi?.description).toBe('test'); expect(b._def.zodOpenApi?.openapi?.description).toBe('test2'); expect( - b._def.zodOpenApi?.[previousSymbol]?._def.zodOpenApi?.openapi?.description, + b._def.zodOpenApi?.[previousSymbol]?._def.zodOpenApi?.openapi + ?.description, ).toBe('test'); }); diff --git a/src/extendZod.ts b/src/extendZod.ts index 3cca5ec..149daee 100644 --- a/src/extendZod.ts +++ b/src/extendZod.ts @@ -1,6 +1,5 @@ import type { ZodRawShape, ZodTypeDef, z } from 'zod'; -import './extendZodTypes'; import { currentSymbol, previousSymbol } from './extendZodTypes'; type ZodOpenApiMetadataDef = NonNullable; diff --git a/src/extendZodTypes.ts b/src/extendZodTypes.ts index e50e23c..c4ff49d 100644 --- a/src/extendZodTypes.ts +++ b/src/extendZodTypes.ts @@ -7,8 +7,8 @@ type SchemaObject = oas30.SchemaObject & oas31.SchemaObject; type ReplaceDate = T extends Date ? Date | string : T; -export const currentSymbol = Symbol("current"); -export const previousSymbol = Symbol("previous"); +export const currentSymbol = Symbol('current'); +export const previousSymbol = Symbol('previous'); /** * zod-openapi metadata diff --git a/tsconfig.json b/tsconfig.json index ff183e6..59cef52 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,6 @@ "removeComments": false, "target": "ES2022" }, - "exclude": ["lib*/**/*", "crackle.config.ts"], + "exclude": ["lib*/**/*", "crackle.config.ts", "dist", "api", "extend"], "extends": "skuba/config/tsconfig.json" }