fastify-type-provider-zod
Advanced tools
Comparing version 1.1.8 to 1.1.9
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ { |
import type { FastifySchema, FastifySchemaCompiler, FastifyTypeProvider } from 'fastify'; | ||
import type { FastifySerializerCompiler } from 'fastify/types/schema'; | ||
import type { z, ZodAny, ZodTypeAny } from 'zod'; | ||
declare type FreeformRecord = Record<string, any>; | ||
type FreeformRecord = Record<string, any>; | ||
export interface ZodTypeProvider extends FastifyTypeProvider { | ||
@@ -6,0 +6,0 @@ output: this['input'] extends ZodTypeAny ? z.infer<this['input']> : never; |
@@ -41,3 +41,4 @@ "use strict"; | ||
var zodToJsonSchemaOptions = { | ||
target: 'openApi3' | ||
target: 'openApi3', | ||
$refStrategy: 'none' | ||
}; | ||
@@ -44,0 +45,0 @@ var createJsonSchemaTransform = function (_a) { |
@@ -0,0 +0,0 @@ { |
{ | ||
"name": "fastify-type-provider-zod", | ||
"version": "1.1.8", | ||
"version": "1.1.9", | ||
"description": "Zod Type Provider for Fastify@4", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -0,0 +0,0 @@ # Fastify Type Provider Zod |
@@ -29,2 +29,3 @@ import type { FastifySchema, FastifySchemaCompiler, FastifyTypeProvider } from 'fastify'; | ||
target: 'openApi3', | ||
$refStrategy: 'none', | ||
} as const; | ||
@@ -31,0 +32,0 @@ |
@@ -97,2 +97,50 @@ import fastifySwagger from '@fastify/swagger'; | ||
}); | ||
it('should not generate ref', async () => { | ||
const app = Fastify(); | ||
app.setValidatorCompiler(validatorCompiler); | ||
app.setSerializerCompiler(serializerCompiler); | ||
app.register(fastifySwagger, { | ||
openapi: { | ||
info: { | ||
title: 'SampleApi', | ||
description: 'Sample backend service', | ||
version: '1.0.0', | ||
}, | ||
servers: [], | ||
}, | ||
transform: jsonSchemaTransform, | ||
}); | ||
app.register(fastifySwaggerUI, { | ||
routePrefix: '/documentation', | ||
}); | ||
const TOKEN_SCHEMA = z.string().length(12); | ||
app.after(() => { | ||
app.withTypeProvider<ZodTypeProvider>().route({ | ||
method: 'POST', | ||
url: '/login', | ||
schema: { | ||
body: z.object({ | ||
access_token: TOKEN_SCHEMA, | ||
refresh_token: TOKEN_SCHEMA, | ||
}), | ||
}, | ||
handler: (req, res) => { | ||
res.send('ok'); | ||
}, | ||
}); | ||
}); | ||
await app.ready(); | ||
const openApiSpecResponse = await app.inject().get('/documentation/json'); | ||
const openApiSpec = JSON.parse(openApiSpecResponse.body); | ||
expect(openApiSpec).toMatchSnapshot(); | ||
await validator.validate(openApiSpec, {}); | ||
}); | ||
}); |
@@ -0,0 +0,0 @@ import type { FastifyInstance } from 'fastify'; |
@@ -0,0 +0,0 @@ import type { FastifyInstance } from 'fastify'; |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ import type { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
38069
760
0