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

express-jsdoc-swagger

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-jsdoc-swagger - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

transforms/utils/formatExamples.js

17

index.d.ts

@@ -32,5 +32,16 @@ // Type definitions for express-jsdoc-swagger

interface SecurityObject {
name: string[];
type: string;
scheme: string;
}
interface Security {
[key: string]: SecurityObject;
}
interface Servers {
url: string;
description: string;
variables?: object;
}
interface Options {

@@ -40,4 +51,4 @@ info: InfoObject;

filesPattern: string | string[];
security?: SecurityObject[];
servers?: string[];
security?: Security;
servers?: string[] | Servers[];
exposeSwaggerUI?: boolean;

@@ -44,0 +55,0 @@ swaggerUIPath?: string;

4

package.json
{
"name": "express-jsdoc-swagger",
"version": "1.3.1",
"version": "1.3.2",
"description": "Swagger OpenAPI 3.x generator",

@@ -12,3 +12,3 @@ "main": "index.js",

"merge": "^2.1.0",
"swagger-ui-express": "^4.1.5"
"swagger-ui-express": "^4.1.6"
},

@@ -15,0 +15,0 @@ "devDependencies": {

@@ -5,2 +5,3 @@ const setProperty = require('../utils/setProperty')('parameter');

const formParams = require('./formParams');
const formatExampleValues = require('../utils/formatExamples')('requestBody');

@@ -31,4 +32,8 @@ const REQUIRED = 'required';

const examplesParsed = examples.map(example => (
formatExampleValues(example, contentType)
));
if (hasForm) {
return formParams(currentState, name, body, isRequired, checkExamples(examples));
return formParams(currentState, name, body, isRequired, checkExamples(examplesParsed));
}

@@ -47,3 +52,3 @@

...currentState.content,
...getContent(body.type, contentType, body.description, checkExamples(examples)),
...getContent(body.type, contentType, body.description, checkExamples(examplesParsed)),
},

@@ -50,0 +55,0 @@ };

@@ -5,2 +5,3 @@ const errorMessage = require('../utils/errorMessage');

const getContent = require('./content')('@return');
const formatExampleValues = require('../utils/formatExamples')('responses');

@@ -18,14 +19,7 @@ const DEFAULT_CONTENT_TYPE = 'application/json';

const exampleList = examples[status];
if (exampleList && (contentType === DEFAULT_CONTENT_TYPE || !contentType)) {
Object.keys(exampleList)
.filter(k => typeof exampleList[k].value === 'string')
.forEach(k => {
try {
exampleList[k].value = JSON.parse(exampleList[k].value);
} catch (err) {
errorMessage(`response example for status ${status} with content-type ${contentType} malformed`);
}
});
}
const exampleList = formatExampleValues(
examples[status],
contentType || DEFAULT_CONTENT_TYPE,
status,
);

@@ -32,0 +26,0 @@ return {

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