🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@fastify/type-provider-json-schema-to-ts

Package Overview
Dependencies
Maintainers
17
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/type-provider-json-schema-to-ts

A Type Provider for json-schema-to-ts over Fastify

Source
npmnpm
Version
2.1.1
Version published
Maintainers
17
Created
Source

fastify-type-provider-json-schema-to-ts

A Type Provider for json-schema-to-ts

Plugin definition

Note When using plugin types, withTypeProvider is not required in order to register the plugin

const plugin: FastifyPluginAsyncJsonSchemaToTs = async function (
  fastify,
  _opts
) {
  fastify.get(
    "/",
    {
      schema: {
        body: {
          type: "object",
          properties: {
            x: { type: "string" },
            y: { type: "number" },
            z: { type: "boolean" },
          },
          required: ["x", "y", "z"],
        } as const,
      },
    },
    (req) => {
      /// The `x`, `y`, and `z` types are automatically inferred
      const { x, y, z } = req.body;
    }
  );
};

Keywords

fastify

FAQs

Package last updated on 16 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts