Skip to main content

Built and signed on GitHub Actions

Companion package for https://jsr.io/@klexik/fastify-oas-connector to generate types, routes, security handlers and service file

This package works with Node.jsIt is unknown whether this package works with Deno
This package works with Node.js
It is unknown whether this package works with Deno
JSR Score
100%
Published
7 months ago (1.1.2)

Fastify OpenAPI Connector Generator

Companion package to fastify-openapi-connector usable both programatically and with npx.

fastify-openapi-connector is minimum dependency package, therefore generator has been split into it's own (this) package.

Usage

Use npx:

npx fastify-openapi-generator <options>

Or import the generator usual way and programatically, everything is exported so you can also just pick bits and pieces.

Options

Required

  • --schema-file
    • Path to schema file generated by openapi-typescript.
  • --types-file
    • Path to where types file should be generated.
  • --service-file
    • Path to where service file should be generated.
  • --spec-file
    • Path to OpenAPI spec file

Optional

  • --help
    • Display this
  • --paths-dir
    • Directory to generate route handlers from paths section of OAS.
  • --webhooks-dir
    • Directory to generate route handlers from webhooks section of OAS.
  • --security-dir
    • Directory to generate security handlers.
  • --untyped
    • Indicates that generated handlers should be untyped.
  • --override-types-file
    • Indicates that types file should be overrided if exists.

Example

npx fastify-openapi-connector-generator \
  --schema-file=./src/generated/schema.ts \
  --types-file=./src/generated/types.ts \
  --service-file=./src/generated/service.ts \
  --paths-dir=./src/paths \
  --webhooks-dir=./src/webhooks \
  --security-dir=./src/security \
  --spec-file=./spec.yaml \
  --override-types-file
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@klexik/fastify-oas-generator

Import symbol

import * as mod from "@klexik/fastify-oas-generator";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@klexik/fastify-oas-generator";

Add Package

npx jsr add @klexik/fastify-oas-generator

Import symbol

import * as mod from "@klexik/fastify-oas-generator";

Add Package

yarn dlx jsr add @klexik/fastify-oas-generator

Import symbol

import * as mod from "@klexik/fastify-oas-generator";

Add Package

pnpm dlx jsr add @klexik/fastify-oas-generator

Import symbol

import * as mod from "@klexik/fastify-oas-generator";