New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.1 to 2.3.0

44

dist/generate.js

@@ -106,2 +106,11 @@ "use strict";

};
const getRouteParameters = (symbol) => symbol
.getJsDocTags()
.filter((tag) => tag.name === 'routeParam')
.flatMap((tag) => tag.text)
.filter(utils_1.isDefined)
.map((symbolDisplayPart) => symbolDisplayPart.text)
.map((tag) => tag.trim())
.map((tagString) => tagString.split(' '))
.map((tag) => [tag[0], tag.slice(1).join(' ') || undefined]);
const getRouteDeclaration = (ctx, components, symbol) => {

@@ -113,2 +122,3 @@ var _a;

const routeInput = getRouteInput(ctx, symbol);
const routeParameterDescriptions = new Map(getRouteParameters(symbol));
const operationId = (_a = getRouteOperationId(symbol)) !== null && _a !== void 0 ? _a : symbol.escapedName.toString();

@@ -130,3 +140,3 @@ if (!routeInput) {

const parameters = [
...typeToRequestParameters(ctx, 'path', routeParams),
...typeToRequestParameters(ctx, 'path', routeParams, routeParameterDescriptions),
...typeToRequestParameters(ctx, 'query', query),

@@ -503,9 +513,23 @@ ...typeToRequestParameters(ctx, 'header', headers),

};
const typeToRequestParameters = (ctx, in_, type) => {
const typeToRequestParameters = (ctx, in_, type, descriptions) => {
if (!type)
return [];
const props = ctx.checker.getPropertiesOfType(type);
if (descriptions) {
const propNames = new Set(props.map((prop) => prop.name));
const extraneousDescriptions = [...descriptions.keys()].filter((name) => !propNames.has(name));
if (extraneousDescriptions.length > 0) {
throw new Error(`Descriptions provided for unmatched ${in_} parameters: ${extraneousDescriptions.join(', ')}`);
}
}
return props.map((prop) => {
const description = getDescriptionFromComment(ctx, prop);
return Object.assign({ name: prop.name, in: in_, required: in_ === 'path' ? true : !(0, utils_1.isOptional)(prop), schema: { type: 'string' } }, (description ? { description } : undefined));
const example = getExampleValue(prop);
return Object.assign({ name: prop.name, in: in_, required: in_ === 'path' ? true : !(0, utils_1.isOptional)(prop), schema: Object.assign({ type: 'string' }, (example ? { example } : undefined)) }, (descriptions
? descriptions.get(prop.name)
? { description: descriptions.get(prop.name) }
: undefined
: description
? { description }
: undefined));
});

@@ -518,3 +542,5 @@ };

result[prop.name] = {
schema: { type: 'string' },
schema: {
type: 'string',
},
required: !(0, utils_1.isOptional)(prop),

@@ -527,4 +553,12 @@ };

const description = symbol ? getDescriptionFromComment(ctx, symbol) : '';
return Object.assign({}, (description ? { description } : undefined));
const example = symbol ? getExampleValue(symbol) : undefined;
return Object.assign(Object.assign({}, (description ? { description } : undefined)), (example ? { example } : undefined));
};
const getExampleValue = (symbol) => symbol
.getJsDocTags()
.filter((tag) => tag.name === 'example')
.flatMap((tag) => tag.text)
.filter(utils_1.isDefined)
.map((symbolDisplayPart) => symbolDisplayPart.text)
.map((tag) => tag.trim())[0];
const typeToSchema = (ctx, components, type, options = {}) => {

@@ -531,0 +565,0 @@ var _a;

2

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

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

@@ -46,3 +46,5 @@ # typera-openapi - OpenAPI generator for typera

const bodyCodec = t.type({
/** Descriptions are also supported in io-ts codecs */
/** Descriptions are also supported in io-ts codecs
* @example Lets you set an example value for a particular property
*/
name: t.string

@@ -57,2 +59,4 @@ })

*
* @routeParam myRouteParam Description for route parameter
*
* @response 200 Success response description.

@@ -59,0 +63,0 @@ * @response 400 Another description for a response. This one

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