Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use JSONObject for transform. #726

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ declare namespace fastifySwagger {
/**
* custom function to transform the route's schema and url
*/
transform?: <S extends FastifySchema = FastifySchema>({ schema, url }: { schema: S, url: string }) => { schema: JSONObject, url: string };
transform?: <S extends FastifySchema = FastifySchema>({ schema, url }: { schema: S, url: string }) => { schema: FastifySchema, url: string };

refResolver?: {
/** Clone the input schema without changing it. Default to `false`. */
Expand Down
4 changes: 2 additions & 2 deletions test/types/http2-types.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fastify from 'fastify';
import fastifySwagger, {JSONObject} from '../..';
import fastifySwagger from '../..';
import { minimalOpenApiV3Document } from './minimal-openapiV3-document';

const app = fastify({
Expand All @@ -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, {
Expand Down
4 changes: 2 additions & 2 deletions test/types/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fastifySwagger, {
SwaggerOptions,
FastifySwaggerInitOAuthOptions,
FastifySwaggerUiConfigOptions,
FastifySwaggerUiHooksOptions, JSONObject,
FastifySwaggerUiHooksOptions,
} from "../.."
import { minimalOpenApiV3Document } from './minimal-openapiV3-document';
import { expectType } from "tsd";
Expand All @@ -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, {
Expand Down