@emdgroup/tapir
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.19 • Public • Published

tapir

Generate TypeScript assertions and type guards from OpenAPI specs

Synopsis

yarn add --dev @emdgroup/tapir
yarn tapir openapi.yml dir/to/lib/

# or use - to read from stdin
cat openapi.yml | yarn tapir - dist/

This will create the following files:

dist/
  types.d.ts
  types.js

The generated files are self-contained and tree-shakable. There are no runtime dependencies on tapir or any other package.

The following properties should be set in the package.json file to make the package work across node and browser environments:

{
    "types": "dist/types.d.ts",
    "main": "dist/types.js"
}

Supported OpenAPI schemas

  • Responses
  • Request bodies
  • Path parameters
  • Query parameters

Missing:

  • Headers

Supported Input Validation

Tested:

  • Core Types: boolean, string, number, integer
    • enum
    • nullable
    • minLength
    • maxLength
    • minimum
    • maximum
    • exclusiveMinimum
    • exclusiveMaximum
    • multipleOf
    • format
    • not
    • pattern
  • Objects:
    • required
    • allOf, anyOf and oneOf
    • additionalProperties with a boolean
  • Arrays:
    • items
    • minItems
    • maxItems
    • uniqueItems

Untested:

  • Any Type
  • Core Types: boolean, string, number, integer
    • readOnly
    • writeOnly
  • Objects:
    • additionalProperties with a schema
    • minProperties
    • maxProperties
    • xml

Package Sidebar

Install

npm i @emdgroup/tapir

Weekly Downloads

43

Version

1.0.0-beta.19

License

Apache-2.0

Unpacked Size

110 kB

Total Files

68

Last publish

Collaborators

  • monken
  • juaquins