New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

openapi-to-typescript

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-to-typescript - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

dist/formatter.js

22

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("source-map-support/register");
const store_1 = require("./store");
const refs_1 = require("./refs");
const compile_1 = require("./compile");
const route_definition_1 = require("./route-definition");
const operation_1 = require("./operation");
const formatters_1 = require("./formatters");
exports.GenerateTypings = async (parsedOpenAPISchema, { outputStrategies = [
formatters_1.ResultTypeFormatter,
formatters_1.RequestTypeFormatter,
] } = {}) => {
exports.GenerateTypings = async (parsedOpenAPISchema) => {
const { paths, components: { schemas } } = parsedOpenAPISchema;
const typeStore = {};
const typeStore = new store_1.Store();
new refs_1.InternalRefRewriter().rewrite(parsedOpenAPISchema.components.schemas);
new refs_1.InternalRefRewriter().rewrite(parsedOpenAPISchema.paths);
for (const schemaName of Object.keys(schemas)) {
typeStore[schemaName] = await compile_1.compileSchema(schemas[schemaName], schemaName);
typeStore.assign(await new formatters_1.SchemaFormatter(schemas[schemaName], schemaName).render());
}
for (const pathName of Object.keys(paths)) {
for (const method of Object.keys(paths[pathName])) {
const route = new route_definition_1.RouteDefinition(paths[pathName][method], { pathName, method });
for (const Formatter of outputStrategies) {
const formatted = new Formatter(route);
typeStore[formatted.typeName()] = await formatted.toTypescript();
const operation = new operation_1.Operation(paths[pathName][method], { pathName, method });
for (const Formatter of formatters_1.defaultOperationFormatters) {
typeStore.assign(await new Formatter(operation).render());
}
}
}
return Object.values(typeStore).filter(t => t).join('\n');
return typeStore;
};
//# sourceMappingURL=index.js.map
{
"name": "openapi-to-typescript",
"version": "1.0.0",
"version": "2.0.0",
"description": "Generate TypeScript typings based on an OpenAPI schema object.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -6,2 +6,20 @@ # openapi-to-typescript

[![Greenkeeper badge](https://badges.greenkeeper.io/ifroz/openapi-to-typescript.svg)](https://greenkeeper.io/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
Generate TypeScript typings based on az OpenAPI3 schema definition.
# Install
`npm install openapi-to-typescript`
`yarn add openapi-to-typescript`
# Usage
```javascript
const { GenerateTypings } = require('openapi-to-typescript')
const generatedTypescript = await GenerateTypings(openapiSchema)
fs.writeFileSync('out.d.ts', generatedTypescript.toString())
```
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc