From 3a57a255c6f2161198d8085a413bdd4be8f570d6 Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Mon, 5 Jun 2023 07:55:35 +0900 Subject: [PATCH] Don't use JSONObject for `transform`. --- index.d.ts | 2 +- test/types/http2-types.test.ts | 4 ++-- test/types/types.test.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index f5afb859..a48a2ba6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -124,7 +124,7 @@ declare namespace fastifySwagger { /** * custom function to transform the route's schema and url */ - transform?: ({ schema, url }: { schema: S, url: string }) => { schema: JSONObject, url: string }; + transform?: ({ schema, url }: { schema: S, url: string }) => { schema: FastifySchema, url: string }; refResolver?: { /** Clone the input schema without changing it. Default to `false`. */ diff --git a/test/types/http2-types.test.ts b/test/types/http2-types.test.ts index cd87fc2c..c0da4a27 100644 --- a/test/types/http2-types.test.ts +++ b/test/types/http2-types.test.ts @@ -1,5 +1,5 @@ import fastify from 'fastify'; -import fastifySwagger, {JSONObject} from '../..'; +import fastifySwagger from '../..'; import { minimalOpenApiV3Document } from './minimal-openapiV3-document'; const app = fastify({ @@ -9,7 +9,7 @@ const app = fastify({ app.register(fastifySwagger); app.register(fastifySwagger, {}); app.register(fastifySwagger, { transform: ({schema, url}) => ({ - schema: schema as unknown as JSONObject, + schema: schema, url: url, })}); app.register(fastifySwagger, { diff --git a/test/types/types.test.ts b/test/types/types.test.ts index 4fbdcf3a..25c2a82c 100644 --- a/test/types/types.test.ts +++ b/test/types/types.test.ts @@ -3,7 +3,7 @@ import fastifySwagger, { SwaggerOptions, FastifySwaggerInitOAuthOptions, FastifySwaggerUiConfigOptions, - FastifySwaggerUiHooksOptions, JSONObject, + FastifySwaggerUiHooksOptions, } from "../.." import { minimalOpenApiV3Document } from './minimal-openapiV3-document'; import { expectType } from "tsd"; @@ -30,7 +30,7 @@ const uiHooks: FastifySwaggerUiHooksOptions = { app.register(fastifySwagger); app.register(fastifySwagger, {}); app.register(fastifySwagger, { transform: ({schema, url}) => ({ - schema: schema as unknown as JSONObject, + schema: schema, url: url, })}); app.register(fastifySwagger, {