express-jsdoc-swagger
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -7,4 +7,5 @@ // Type definitions for express-jsdoc-swagger | ||
import { EventEmitter } from 'events'; | ||
import express from 'express'; | ||
import { EventEmitter } from "events"; | ||
import express from "express"; | ||
import { SwaggerUiOptions } from "swagger-ui-express"; | ||
@@ -52,3 +53,3 @@ interface ContactObject { | ||
security?: Security; | ||
servers?: string[] | Servers[]; | ||
servers?: string[] | Servers[]; | ||
exposeSwaggerUI?: boolean; | ||
@@ -58,2 +59,3 @@ swaggerUIPath?: string; | ||
apiDocsPath?: string; | ||
swaggerUiOptions?: SwaggerUiOptions; | ||
} | ||
@@ -60,0 +62,0 @@ |
@@ -35,3 +35,3 @@ const swaggerUi = require('swagger-ui-express'); | ||
next(); | ||
}, swaggerUi.serve, swaggerUi.setup()); | ||
}, swaggerUi.serve, swaggerUi.setup(undefined, options.swaggerUiOptions)); | ||
} | ||
@@ -38,0 +38,0 @@ |
{ | ||
"name": "express-jsdoc-swagger", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "Swagger OpenAPI 3.x generator", | ||
@@ -11,14 +11,14 @@ "main": "index.js", | ||
"glob": "^7.1.6", | ||
"merge": "^2.1.0", | ||
"merge": "^2.1.1", | ||
"swagger-ui-express": "^4.1.6" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^9.1.2", | ||
"@commitlint/config-conventional": "^10.0.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-base": "^14.1.0", | ||
"eslint-plugin-import": "^2.20.2", | ||
"eslint-plugin-jest": "^23.13.1", | ||
"husky": "^4.2.5", | ||
"jest": "^26.0.1" | ||
"@commitlint/cli": "^11.0.0", | ||
"@commitlint/config-conventional": "^11.0.0", | ||
"eslint": "^7.19.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.1.3", | ||
"husky": "^4.3.8", | ||
"jest": "^26.6.3" | ||
}, | ||
@@ -41,3 +41,3 @@ "engines": { | ||
"type": "git", | ||
"url": "git+https://github.com/BRIKEV/express-jsdoc-swagger.git" | ||
"url": "git+https://github.com/brikev/express-jsdoc-swagger.git" | ||
}, | ||
@@ -55,8 +55,8 @@ "keywords": [ | ||
], | ||
"author": "BRIKEV (https://github.com/BRIKEV)", | ||
"author": "BRIKEV (https://github.com/brikev)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/BRIKEV/express-jsdoc-swagger/issues" | ||
"url": "https://github.com/brikev/express-jsdoc-swagger/issues" | ||
}, | ||
"homepage": "https://brikev.github.io/express-jsdoc-swagger-docs/#/" | ||
} |
@@ -57,3 +57,3 @@ ![npm](https://img.shields.io/npm/v/express-jsdoc-swagger) | ||
* GET /api/v1 | ||
* @summary This is the summary or description of the endpoint | ||
* @summary This is the summary of the endpoint | ||
* @return {object} 200 - success response | ||
@@ -106,3 +106,3 @@ */ | ||
* GET /api/v1/albums | ||
* @summary This is the summary or description of the endpoint | ||
* @summary This is the summary of the endpoint | ||
* @tags album | ||
@@ -122,3 +122,3 @@ * @return {array<Song>} 200 - success response - application/json | ||
* GET /api/v1/album | ||
* @summary This is the summary or description of the endpoint | ||
* @summary This is the summary of the endpoint | ||
* @security BasicAuth | ||
@@ -141,3 +141,3 @@ * @tags album | ||
* GET /api/v1/albums | ||
* @summary This is the summary or description of the endpoint | ||
* @summary This is the summary of the endpoint | ||
* @tags album | ||
@@ -181,2 +181,5 @@ * @return {array<Song>} 200 - success response - application/json | ||
<td align="center"><a href="https://github.com/juliendu11"><img src="https://avatars0.githubusercontent.com/u/18739442?v=4?s=100" width="100px;" alt=""/><br /><sub><b>juliendu11</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=juliendu11" title="Code">💻</a></td> | ||
<td align="center"><a href="https://me.io"><img src="https://avatars.githubusercontent.com/u/45731?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mohamed Meabed</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=meabed" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/ofarukaydin"><img src="https://avatars.githubusercontent.com/u/32788963?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Faruk Aydın</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=ofarukaydin" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/dahlmo"><img src="https://avatars.githubusercontent.com/u/23076026?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dahlmo</b></sub></a><br /><a href="https://github.com/BRIKEV/express-jsdoc-swagger/commits?author=dahlmo" title="Code">💻</a></td> | ||
</tr> | ||
@@ -183,0 +186,0 @@ </table> |
@@ -22,2 +22,4 @@ const examplesGenerator = require('./examples'); | ||
const formatDescription = description => (description || {}).description || undefined; | ||
const setRequestBody = (lowerCaseMethod, bodyValues, requestExamples) => { | ||
@@ -36,2 +38,3 @@ const hasBodyValues = bodyValues.length > 0; | ||
const summary = getTagInfo(tags, 'summary'); | ||
const description = getTagInfo(tags, 'description'); | ||
const deprecated = getTagInfo(tags, 'deprecated'); | ||
@@ -54,2 +57,3 @@ const isDeprecated = !!deprecated; | ||
summary, | ||
description, | ||
isDeprecated, | ||
@@ -73,3 +77,11 @@ responses, | ||
const { | ||
summary, bodyValues, isDeprecated, responses, parameters, tagsValues, securityValues, examples, | ||
summary, | ||
description, | ||
bodyValues, | ||
isDeprecated, | ||
responses, | ||
parameters, | ||
tagsValues, | ||
securityValues, | ||
examples, | ||
} = pathValues(tags); | ||
@@ -84,2 +96,3 @@ const requestExamples = examples.filter(example => example.type === 'request'); | ||
summary: formatSummary(summary), | ||
description: formatDescription(description), | ||
security: formatSecurity(securityValues), | ||
@@ -86,0 +99,0 @@ responses, |
@@ -25,3 +25,3 @@ const errorMessage = require('../utils/errorMessage'); | ||
type: type.expression.name, | ||
items: parseItems, | ||
items: parseItems.items ? parseItems.items : parseItems, | ||
}; | ||
@@ -28,0 +28,0 @@ } |
@@ -15,3 +15,3 @@ const errorMessage = require('./errorMessage'); | ||
schema = { | ||
[schemaType]: types.map(type => refSchema(type.name)), | ||
[schemaType]: types.map(type => refSchema(type)), | ||
}; | ||
@@ -18,0 +18,0 @@ } else { |
@@ -23,3 +23,2 @@ const errorMessage = require('./errorMessage'); | ||
module.exports = formatJSONExamples; |
@@ -6,6 +6,33 @@ const validateTypes = require('./validateTypes'); | ||
const refSchema = value => { | ||
// support * @return {array<Song|Album>} 200 - fetch Home Content response | ||
if (value && value.type === 'UnionType') { | ||
const items = []; | ||
value.elements.forEach(el => { | ||
const isPrimitive = validateTypes(el.name); | ||
items.push(isPrimitive ? { type: el.name } : { $ref: `${REF_ROUTE}${el.name}` }); | ||
}); | ||
return { | ||
anyOf: items, | ||
}; | ||
} | ||
// support * @property {anyOf|Song[]|Album|string|string[]} firstSong | ||
if (value && value.expression && value.expression.name.toLowerCase() === 'array' && value.type === 'TypeApplication') { | ||
const isPrimitive = validateTypes(value.applications[0].name); | ||
return isPrimitive ? { | ||
type: 'array', | ||
items: { type: value.applications[0].name }, | ||
} : { | ||
type: 'array', | ||
items: { $ref: `${REF_ROUTE}${value.applications[0].name}` }, | ||
}; | ||
} | ||
if (!value) return {}; | ||
const isPrimitive = validateTypes(value); | ||
const schema = isPrimitive ? { type: value } : { $ref: `${REF_ROUTE}${value}` }; | ||
return schema; | ||
const nameValue = value.name || value; | ||
// support null | ||
if (nameValue.type === 'NullLiteral') return {}; | ||
const isPrimitive = validateTypes(nameValue); | ||
return isPrimitive ? { type: nameValue } : { $ref: `${REF_ROUTE}${nameValue}` }; | ||
}; | ||
@@ -15,3 +42,3 @@ | ||
...itemAcc, | ||
...refSchema(itemTypes.name), | ||
...refSchema(itemTypes), | ||
}), {}); | ||
@@ -18,0 +45,0 @@ |
Sorry, the diff of this file is not supported yet
63838
1225
189
Updatedmerge@^2.1.1