
Security News
Socket Security Analysis Is Now One Click Away on npm
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.
gofer-openapi
Advanced tools
gofer-openapiCLI and Library to assist in converting OpenAPI Specifications into working Gofer clients.

The basic idea is that this tool reads in an OpenAPI 3.x specification file
and outputs a TypeScript file which contains all of the required type
declarations, as well as a definition of a class which extends Gofer.
You may then subclass this class to add a valid constructor as well as any hand-written methods you wish to add. By keeping the files separate, you are free to regenerate the auto-generated base class as often as you need (as the OpenAPI spec changes).
If you plan to use this regularly in your project, you may wish to install it locally first:
$ npm i gofer-openapi
For current CLI usage, see:
$ npx gofer-openapi --help
$ npx gofer-openapi \
--class=PetStoreBase \
< petstore.yml \
> petstore-base.ts
Now you can create your subclass:
// File: petstore.ts
import { PetStoreBase } from './petstore-base';
export * from './petstore-base';
export class PetStore extends PetStoreBase {
constructor() {
super({}, 'PetStore', '1.0.0');
}
addTwoDogs() {
return this.addPet([ /* ... */ ]);
}
}
And use it:
import { PetStore } from './petstore';
async function query() {
const client = new PetStore();
const res = await client.addTwoDogs();
const res2 = await client.someAutoGeneratedMethod();
}
$ npx gofer-openapi \
--class=PetStoreBase \
--format=js \
< petstore.yml \
> petstore-base.js
# optionally, but highly recommended, *also* run:
$ npx gofer-openapi \
--class=PetStoreBase \
--format=dts \
< petstore.yml \
> petstore-base.d.ts
This will get you a CommonJS JavaScript file and accompanying TypeScript declaration file, which you can now include in your existing JavaScript project without needing to transpile.
The class and usage examples above will basically work exactly the same.
import { readFileSync } from 'fs';
import { goferFromOpenAPI } from 'gofer-openapi';
const typeScriptSrc = goferFromOpenAPI(
readFileSync('petstore.yml', 'utf8'),
{ className: 'PetStore', format: 'ts' }
);
See the the type declarations for full usage.
$ npm run watch
Runs the typescript compiler so you can edit the files in src/
FAQs
Gofer Openapi
We found that gofer-openapi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.

Security News
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.

Product
Socket is now scanning AI agent skills across multiple languages and ecosystems, detecting malicious behavior before developers install, starting with skills.sh's 60,000+ skills.