Magical SDK generation from an OpenAPI definition 🪄
api
is a library that facilitates creating an SDK from an OpenAPI definition. You can use its codegen offering to create an opinionated SDK for TypeScript or JS (+ TypeScript types).
$ npx api install https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json
const petstore = require('@api/petstore');
petstore.listPets().then(({ data }) => {
console.log(`My pets name is ${data[0].name}!`);
});
Or you can use it dynamically (though you won't have fancy TypeScript types to help you out!):
const petstore = require('api')(
'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json'
);
petstore.listPets().then(({ data })) => {
console.log(`My pets name is ${data[0].name}!`);
});
<small>5.0.3 (2022-11-28)</small>
- v5.0.3 (7aba675)
- test: refreshing the unit test dataset (4dad793)
- chore(deps-dev): bump husky from 8.0.1 to 8.0.2 (#568) (113e898), closes #568
- chore(deps): bump readmeio/rdme from 8.0.0 to 8.1.1 (#573) (6f96efa), closes #573
- chore(deps): bumping out of date deps (#575) (ae55a13), closes #575
- fix: compatibility with yarn installs where
package.json
needs version
(#574) (0913923), closes #574
- ci: disabling updates to
find-cache-dir
as it's esm-only now (e21a975)