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.2.0 to 2.2.1

4

dist/context.d.ts
import * as ts from 'typescript';
export declare type LogLevel = 'verbose' | 'info' | 'warn' | 'error';
export declare type Logger = (location: string, level: LogLevel, ...messages: any[]) => void;
export type LogLevel = 'verbose' | 'info' | 'warn' | 'error';
export type Logger = (location: string, level: LogLevel, ...messages: any[]) => void;
export interface Context {

@@ -5,0 +5,0 @@ checker: ts.TypeChecker;

@@ -354,7 +354,14 @@ "use strict";

else if (responseType.isUnion()) {
responseType.types.forEach((type) => {
const responseDef = getResponseDefinition(ctx, components, descriptions, type);
if (responseDef)
result[responseDef.status] = responseDef.response;
const responsesByStatusCode = {};
responseType.types
.flatMap((type) => getResponseDefinition(ctx, components, descriptions, type) || [])
.forEach(({ status, response }) => {
if (responsesByStatusCode[status])
responsesByStatusCode[status].push(response);
else
responsesByStatusCode[status] = [response];
});
for (const status in responsesByStatusCode) {
result[status] = mergeResponses(...responsesByStatusCode[status]);
}
}

@@ -380,2 +387,37 @@ if (Object.keys(result).length === 0) {

.filter(utils_1.isDefined));
const mergeResponses = (...responses) => {
var _a, _b;
if (responses.length === 1)
return responses[0];
const mergedResponse = {
description: '',
content: {},
};
for (const response of responses) {
const content = response.content;
if (!content)
continue;
for (const mediaType in content) {
const schema = (_a = content[mediaType]) === null || _a === void 0 ? void 0 : _a.schema;
if (!schema)
continue;
const mergedSchema = (_b = mergedResponse.content[mediaType]) === null || _b === void 0 ? void 0 : _b.schema;
if (!mergedSchema) {
mergedResponse.content[mediaType] = { schema };
}
else if (!mergedSchema.oneOf) {
mergedResponse.content[mediaType].schema = {
oneOf: [mergedSchema, schema],
};
}
else {
mergedSchema.oneOf.push(schema);
}
}
if (response.description) {
mergedResponse.description = response.description;
}
}
return mergedResponse;
};
const getResponseDefinition = (ctx, components, responseDescriptions, responseType) => {

@@ -544,2 +586,6 @@ const statusSymbol = responseType.getProperty('status');

}
if ((0, utils_1.isReadonlyType)(type) && type.aliasTypeArguments) {
const readonlyType = type.aliasTypeArguments[0];
return typeToSchema(ctx, components, readonlyType, options);
}
if ((0, utils_1.isObjectType)(type) ||

@@ -546,0 +592,0 @@ (type.isIntersection() &&

@@ -17,2 +17,3 @@ import * as ts from 'typescript';

export declare const isTypeAlias: (symbol: ts.Symbol) => boolean;
export declare const isReadonlyType: (type: ts.Type) => boolean;
export declare const isDateType: (type: ts.Type) => boolean;

@@ -19,0 +20,0 @@ export declare const isBufferType: (type: ts.Type) => boolean;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPromisePayloadType = exports.getBrandedType = exports.getPropertyType = exports.isStreamingBodyType = exports.isBufferType = exports.isDateType = exports.isTypeAlias = exports.isInterface = exports.isNullType = exports.isUndefinedType = exports.isStringLiteralType = exports.isNumberLiteralType = exports.isBooleanLiteralType = exports.isBooleanType = exports.isNumberType = exports.isStringType = exports.isObjectType = exports.isArrayType = exports.isOptional = exports.isDefined = void 0;
exports.getPromisePayloadType = exports.getBrandedType = exports.getPropertyType = exports.isStreamingBodyType = exports.isBufferType = exports.isDateType = exports.isReadonlyType = exports.isTypeAlias = exports.isInterface = exports.isNullType = exports.isUndefinedType = exports.isStringLiteralType = exports.isNumberLiteralType = exports.isBooleanLiteralType = exports.isBooleanType = exports.isNumberType = exports.isStringType = exports.isObjectType = exports.isArrayType = exports.isOptional = exports.isDefined = void 0;
const ts = require("typescript");

@@ -33,2 +33,4 @@ const isDefined = (value) => value !== undefined;

exports.isTypeAlias = isTypeAlias;
const isReadonlyType = (type) => { var _a; return ((_a = type.aliasSymbol) === null || _a === void 0 ? void 0 : _a.escapedName) === 'Readonly'; };
exports.isReadonlyType = isReadonlyType;
// Check for a specific object type based on type name and property names

@@ -35,0 +37,0 @@ const duckTypeChecker = (name, properties) => (type) => {

{
"name": "typera-openapi",
"version": "2.2.0",
"version": "2.2.1",
"description": "Generate OpenAPI spec from typera routes",

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

@@ -227,12 +227,13 @@ # typera-openapi - OpenAPI generator for typera

| Information | Source |
| ------------ | -------------------------------------------------- |
| method | Which `route` method is called, e.g. `route.get()` |
| path | The parameter of e.g. `route.get()` |
| summary | JSDoc comment's `@summary` tag |
| description | JSDoc comment's text |
| tags | JSDoc comment's `@tags` |
| parameters | See table below |
| request body | See table below |
| responses | See table below |
| Information | Source |
| ------------ | --------------------------------------------------------------------------------------- |
| method | Which `route` method is called, e.g. `route.get()` |
| path | The parameter of e.g. `route.get()` |
| summary | JSDoc comment's `@summary` tag |
| description | JSDoc comment's text |
| tags | JSDoc comment's `@tags` |
| operationId | Name of the variable that holds the route, override with JSDoc comment's `@operationId` |
| parameters | See table below |
| request body | See table below |
| responses | See table below |

@@ -239,0 +240,0 @@ The JSDoc comment of the router can be used to add information to all its

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