GitHub - janwilmake/oapis.npm: Attempt at making a package manager for auto-generated OpenAPI SDKs (original) (raw)

oapis package manager

This repo shows a proof of concept for a package manager for auto-generated OpenAPI SDKs.

You can use it for any domain that has an openapi.json at the root.

To set this up, first you need to instruct npm (or yarn/pnpm, etc) to install anything from the @oapis scope via our server:

npm config set @oapis:registry https://npm.oapis.org --location=project

Now, any OpenAPI SDK can be installed using:

npm i @oapis/{domain}

or

npm i @oapis/{domain}__{operationId}

As an alternative to the above, I created this cli that allows one command to install any OpenAPI as SDK:

npx oapis install {domain}

The proof of concept generates the required files automatically before it serves them such that the installed package is always in sync with the then available OpenAPI spec. This means there is no support for versioning at this point, 1.0.0 is always the most revent version upon installation. If desired, we could add version support through a date system at a later point, having it generate version YYYY.MMDD.HHMM every time someone fetches the available versions and there is a difference from the previous OpenAPI. Another option would be to use the version flag available in the OpenAPI itself, but this may not be updated by all openapi creators.

The proof of concept does not generate valid typescript/javascript code yet. However, my previous experience is that this is quite straightforward to do for the majority of OpenAPIs.

TODO: