JSPM

  • Created
  • Published
  • Downloads 1881
  • Score
    100M100P100Q113293F
  • License MIT

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tspec) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    tspec

    Type-based OpenAPI Specification

    How to use?

    import { DefineApiSpec, generateSpec } from 'tspec'
    
    export type GetBookApiSpec = DefineApiSpec<{
      url: 'GET /books/{id}',
      summary: 'Retrieve a book',
      description: 'Retrieve a book',
      tags: ['Book'],
      path: {
        /**
         * Book id
         * @example 1234
         */
        id: number,
      },
      response: Book,
    }>;
    
    // generate OpenAPI Spec
    const openAPISpec = generateSpec(options);
    

    Philosophy

    Type is all you need for generating Open API Specification

    No need to tediously write OpenAPI Schema for each API.

    You just need to pass your types to ApiSpec to generate an OpenAPI Specification.

    Utilize ApiSpec types as a SSOT(Single Source of Truth) for type-hints, documentation and validation