Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typera-openapi

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typera-openapi - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

26

dist/generate.js

@@ -19,3 +19,3 @@ "use strict";

ts.forEachChild(sourceFile, (node) => {
const paths = visit(context_1.context(checker, sourceFile, log, node), node);
const paths = visitTopLevelNode(context_1.context(checker, sourceFile, log, node), node);
if (paths) {

@@ -29,3 +29,3 @@ result.push({ fileName: sourceFile.fileName, paths });

exports.generate = generate;
const visit = (ctx, node) => {
const visitTopLevelNode = (ctx, node) => {
if (ts.isExportAssignment(node) && !node.isExportEquals) {

@@ -38,5 +38,11 @@ // 'export default' statement

argSymbols.forEach((symbol) => {
const location = symbol.valueDeclaration;
if (!location)
let location = symbol.valueDeclaration;
if (!location && symbol.flags & ts.SymbolFlags.Alias) {
symbol = ctx.checker.getAliasedSymbol(symbol);
location = symbol.valueDeclaration;
}
if (!location) {
ctx.log('warn', `Could not find the definition of router arg ${symbol.name}`);
return;
}
const routeDeclaration = getRouteDeclaration(context_1.withLocation(ctx, location), symbol);

@@ -78,4 +84,6 @@ if (routeDeclaration) {

const routeInput = getRouteInput(ctx, symbol);
if (!routeInput)
if (!routeInput) {
ctx.log('warn', `Could not determine route input for symbol ${symbol.name}`);
return;
}
const { method, path, requestNode, body, query, headers, routeParams, cookies, } = routeInput;

@@ -137,5 +145,9 @@ const responses = getResponseTypes(ctx, symbol);

const declaration = symbol.valueDeclaration;
if (!declaration || !ts.isVariableDeclaration(declaration))
if (!declaration)
return;
let expr = declaration.initializer;
let expr = ts.isVariableDeclaration(declaration)
? declaration.initializer
: ts.isExportAssignment(declaration)
? declaration.expression
: undefined;
if (!expr)

@@ -142,0 +154,0 @@ return;

{
"name": "typera-openapi",
"version": "1.0.0",
"version": "1.0.1",
"description": "Generate OpenAPI spec from typera routes",

@@ -22,3 +22,4 @@ "repository": "https://github.com/akheron/typera-openapi",

"test": "jest",
"doctoc": "doctoc README.md --title '## Table of Contents' && prettier --write README.md"
"doctoc": "doctoc README.md --title '## Table of Contents' && prettier --write README.md",
"prepublishOnly": "yarn clean && yarn build"
},

@@ -25,0 +26,0 @@ "dependencies": {

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