Socket
Socket
Sign inDemoInstall

oatyp

Package Overview
Dependencies
47
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    oatyp

Build Typescript typings from OpenAPI definitions


Version published
Maintainers
1
Install size
13.8 MB
Created

Readme

Source

oatyp

OpenAPI Typescript Generator

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.

FAQs

Last updated on 31 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc