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 2.1.0 to 2.2.0

23

dist/generate.js

@@ -15,2 +15,3 @@ "use strict";

const seenFileNames = new Set();
const seenOperationIds = new Set();
const components = new components_1.Components();

@@ -26,3 +27,3 @@ let paths = {};

ts.forEachChild(sourceFile, (node) => {
const newPaths = visitTopLevelNode((0, context_1.context)(checker, sourceFile, log, node), components, node);
const newPaths = visitTopLevelNode((0, context_1.context)(checker, sourceFile, log, node), components, seenOperationIds, node);
if (newPaths) {

@@ -45,3 +46,3 @@ // TODO: What if a route is defined multiple times?

const isSameFile = (a, b) => path.resolve(a) === path.resolve(b);
const visitTopLevelNode = (ctx, components, node) => {
const visitTopLevelNode = (ctx, components, seenOperationIds, node) => {
if (ts.isExportAssignment(node) && !node.isExportEquals) {

@@ -79,2 +80,10 @@ const prefix = getRouterPrefix(node);

}
if (operation.operationId) {
if (!seenOperationIds.has(operation.operationId)) {
seenOperationIds.add(operation.operationId);
}
else {
ctx.log('warn', `Duplicated operationId ${operation.operationId}. Use @operationId in JSDoc comment to override.`);
}
}
}

@@ -102,2 +111,3 @@ });

const getRouteDeclaration = (ctx, components, symbol) => {
var _a;
const description = getDescriptionFromComment(ctx, symbol);

@@ -107,2 +117,3 @@ const summary = getRouteSummary(symbol);

const routeInput = getRouteInput(ctx, symbol);
const operationId = (_a = getRouteOperationId(symbol)) !== null && _a !== void 0 ? _a : symbol.escapedName.toString();
if (!routeInput) {

@@ -132,3 +143,3 @@ ctx.log('warn', `Could not determine route input for symbol ${symbol.name}`);

method,
Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (summary ? { summary } : undefined)), (description ? { description } : undefined)), (tags && tags.length > 0 ? { tags } : undefined)), (parameters.length > 0 ? { parameters } : undefined)), operationRequestBody(requestBody, contentTypeString)), { responses }),
Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (summary ? { summary } : undefined)), { operationId }), (description ? { description } : undefined)), (tags && tags.length > 0 ? { tags } : undefined)), (parameters.length > 0 ? { parameters } : undefined)), operationRequestBody(requestBody, contentTypeString)), { responses }),
];

@@ -153,2 +164,8 @@ };

.map((tag) => tag.trim());
const getRouteOperationId = (symbol) => symbol
.getJsDocTags()
.filter((tag) => tag.name === 'operationId')
.flatMap((tag) => tag.text)
.filter(utils_1.isDefined)
.map((symbolDisplayPart) => symbolDisplayPart.text)[0];
const getNodeTags = (node) => ts

@@ -155,0 +172,0 @@ .getJSDocTags(node)

2

package.json
{
"name": "typera-openapi",
"version": "2.1.0",
"version": "2.2.0",
"description": "Generate OpenAPI spec from typera routes",

@@ -5,0 +5,0 @@ "repository": "https://github.com/akheron/typera-openapi",

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