# fastify-client-generator

> This Fastify plugin generates automatically one or more clients by leveraging [Fastify Swagger](https://www.npmjs.com/package/@fastify/swagger) and the [OpenAPI Generator](https://openapi-generator.tech/).

Latest version **1.0.1** (published 2024-03-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install fastify-client-generator
pnpm add fastify-client-generator
yarn add fastify-client-generator
bun add fastify-client-generator
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-03-26 |
| First published | 2024-03-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 (+9 in 1 direct dependencies) |
| Install scripts | no |
| Author | Alfonso Graziano |
| Maintainers | alfonso.graziano |

## Links

- npm: https://www.npmjs.com/package/fastify-client-generator
- npm.io page: https://npm.io/package/fastify-client-generator

## Dependencies (4)

- [fastify](https://npm.io/package/fastify.md) ^4.26.2
- [fastify-plugin](https://npm.io/package/fastify-plugin.md) ^4.5.1
- [@fastify/swagger](https://npm.io/package/@fastify/swagger.md) ^8.14.0
- [@openapitools/openapi-generator-cli](https://npm.io/package/@openapitools/openapi-generator-cli.md) ^2.13.1

## Recent versions

- 1.0.1 (latest) — 2024-03-26
- 1.0.0 — 2024-03-26

## README

# Fastify Client Generator

This Fastify plugin generates automatically one or more clients by leveraging [Fastify Swagger](https://www.npmjs.com/package/@fastify/swagger) and the [OpenAPI Generator](https://openapi-generator.tech/).

# How to use it

```js
const fastify = require("fastify")({
  logger: true,
});
const fastifyClientGenerator = require("fastify-client-generator");

const buildApp = async () => {
  //Add here your options
  await fastify.register(fastifyClientGenerator, {
    fastifySwaggerOptions: {
      openapi: {
        info: {
          title: "OpenAPI 3.0 Example",
          description: "Description of the API.",
          version: "0.2.0",
        },
      },
    },
    openApiDefinitionPath: "./openapi.yaml",
    clients: [
      {
        type: "typescript",
        outputPath: "./ts-client",
      },
    ],
  });

  fastify.put(
    "/some-route/:id",
    {
      schema: {
        description: "post some data",
        tags: ["user", "code"],
        summary: "qwerty",
        params: {
          type: "object",
          properties: {
            id: {
              type: "string",
              description: "user id",
            },
          },
        },
        body: {
          type: "object",
          properties: {
            hello: { type: "string" },
            obj: {
              type: "object",
              properties: {
                some: { type: "string" },
              },
            },
          },
        },
        response: {
          201: {
            description: "Successful response",
            type: "object",
            properties: {
              hello: { type: "string" },
            },
          },
          default: {
            description: "Default response",
            type: "object",
            properties: {
              foo: { type: "string" },
            },
          },
        },
      },
    },
    (req, reply) => {}
  );

  await fastify.ready();
};

buildApp();
```

---
_Source: https://npm.io/package/fastify-client-generator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
