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

oatyp

v1.0.0-alpha.33

Published

Build Typescript typings from OpenAPI definitions

Downloads

14

Readme

This tools is inspired from openapi-generator, the purpose is to be able to generate Typescript typings from openapi definitions

We're using ts-morph and axios under the hood.

codecov

Why

Openapi generator is a great tool and it's working fine for simple typescript typings, which I think are the principal use case, It's used by many developers and It's maintained.

BUT, this tool is handling dozen of languages, generating client and server codes via OpenAPI, so obviously some generators are broken or have some annoying bugs (openapi-generator#6332, openapi-generator#7886, openapi-generator#4190, openapi-generator#7887). Some of this bugs are preventing us from using the tool.

I'm not really familiar with Java, and I really need something that works well with Typescript quickly. That's why I've created this package, the ambition is not to support multiple language, supporting Typescript seems fine. And generating code with ts-morph is something pretty easy.

Features

  • Generate typings for each operation's body and response
  • Generate class and methods for each operation, scoped by tags, named after operationId
  • Exposing axios client
  • Handling readonly and writeonly properties
  • Removing prefixes from operationId (role-createcreate, which give Role.create if tag is Role)

How to use

yarn global add oatyp
oatyp -s example/openapi.yaml -d example

It will use the example/openapi.yaml file to ouput generated typescript in the example/ directory.

The --removeTagFromOperationId option

The generated class is scoped by tags, it means that if you have multiple operations with the same tag they all will be available under this tag namespace (e.g. apiInstance.MyTag.myOperationId).

But having the tag name in the operation id (as operation id must be unique across tags) can be redundant, that's why you can enable the --removeTagFromOperationId option that will remove the tag name from the operation id.