
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
parse-openapi
Advanced tools
The OpenAPi v3 parser extracted from openapi-typescript-codegen. So first of all, all credits go to Ferdi Koomen for his work on this great library. Only the parser is needed to render the models, services and hooks with custom templates, hence this stripped down version.
npm install -D parse-openapi openapi-types
import { readFile, writeFile } from 'fs/promises';
import { parse } from 'parse-openapi';
import { renderModel, renderService } from './templates';
import type { OpenAPIV3 } from 'openapi-types';
const specs: OpenAPIV3 = JSON.parse(await readFile('swagger.json', 'utf8'));
const { version, server, models, services } = parse(specs);
models.forEach(model => writeFile(`${model.name}.ts`, renderModel(model)));
services.forEach(service =>
writeFile(`${service.name}.ts`, renderService(service))
);
This could be anything from Handlebars templates to template literals. Here's a minimal example:
import type { Operation, Service } from 'parse-openapi';
const renderOperation = (operation: Operation): string => {
const [result] = operation.results;
return `
/**
* ${operation.summary}
* ${operation.description}
* @returns ${result.type} ${result.description}
${operation.deprecated ? '* @deprecated' : ''}
*/
export function ${operation.name}([...]): Promise<${result.type}> {
return request({
method: '${operation.method}',
path: \`${operation.path}\`,
[...]
});
}`;
};
export default (service: Service) => {
return services.operations.map(renderOperation).join(';');
};
FAQs
OpenAPI v3 parser
The npm package parse-openapi receives a total of 521 weekly downloads. As such, parse-openapi popularity was classified as not popular.
We found that parse-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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.