npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@skywardapps/ts-openapi-gen

v1.4.0

Published

Generator for open api specifications based on Typescript and TypeDoc

Downloads

94

Readme

ts-openapi-gen

A generator for OpenApi documentation based on Typescript, Express, Inversify and TypeDoc.

Overview

Code an API using Express and inversifyJS. Comment it using JSDoc...

Endpoint Code

... and type it using Typescript (NOTE: due to typedoc limitations, only supports 4.0 -> 4.7).

Types

Install typedoc and ts-openapi-gen

yarn add --dev typedoc@~0.22 typedoc-plugin-expand-object-like-types@^0.1 typedoc-plugin-missing-exports@^2.1 ts-openapi-gen

Now generate your OpenApi schema directly from your code -- types and comments extracted, inferred, and included!

yarn run typedoc --json ./docs/typedoc.json --entryPointStrategy Expand --disableSources --plugin typedoc-plugin-expand-object-like-types --plugin typedoc-plugin-missing-exports --pretty src/controllers yarn run ts-openapi-gen --entrypoint ./docs/typedoc.json --out assets/public/openapi.json

Generated OpenApi

Getting Started

This presumes you have a RESTful web-api you are building, utilizing Typescript for typing, JSDoc for commenting, and inversify-express-utils to scaffold your API endpoints on top of express.

Requirements:

  • InversifyJS & inversify-express-utils
  • Typescript 4.7
  • Express

Your project must be in buildable state (node_modules installed, code builds, etc). Point ts-openapi-gen to your root tsconfig file and the location of the entrypoints (the controllers).

Generating the OpenApi Schema

ts-openapi-gen has three parameters:

|Parameter|Description|Required| |--|-|-| | --typedoc | The generated typedoc json file. | :heavy_check_mark: | | --tsconfig | Points to the tsconfig for your project; required to be able to interpret the types included and referenced; defaults to tsconfig.json in the current directory. | | | --out | The name of the file to write the schema to; defaults to openapi.json if not provided. | |

Features

  • Automatically discover published endpoints
  • Inspect annotations and derive:
    • Http Method
    • Paths
  • Inspect JSDoc comments and derive:
    • Short and long comments
    • Descriptions of parameters and return values
  • Reflect Typescript types and derive:
    • Schemas for POST bodies
    • Schemas for API response data
    • Automatically unwrap inversify types (Promise, OkNegotiatedContent, etc)

How to write a web api that can be seamlessly auto-documented

Check out our samples for example projects that can be documented.

How to Contribute

Check out our Contribution Guide! Some examples of what you can do:

  • Start a discussion on a desired feature, then implement it if you can!
  • Submit a PR for a bugfix.
  • Open an issue for a problem you found.
  • Write some documentation.

Authors

Skyward Skyward App Company, LLC

Technologies

TypeScript Express.js NodeJS Swagger

Git GitHub GitHub Actions NPM