
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
swagger-comment-parser
Advanced tools
A fork of swagger-jsdoc that brings a cleaner way to document your code for generating OpenAPI (Swagger) specs.
$ yarn add jsdoc-openapi
const jsdocParser = require("jsdoc-openapi");
// normal OpenAPI definition
const openAPIDefinition = {
openapi: "3.0.0",
info: {
title: "Title of your service",
version: "1.0.0",
}
}
const spec = jsdocParser({
swaggerDefinition: openAPIDefinition,
apis: ["src/**/*.js"] // paths to files with comments to be parsed
});
const jsdocParser = require("jsdoc-openapi");
const swaggerUi = require("swagger-ui-express");
const spec = jsdocParser({
swaggerDefinition: openAPIDefinition,
apis: ["src/routes/my-route.js"]
});
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(spec));
/**
* <METHOD> /<path>
* @<property> {<type>} <name> - <description>
*/
Available properties (so far):
@description@operationId@summary@deprecated@pathParam@queryParam@requestBody@requestBodyForm@responsetypes:
integernumberstringbooleanobject[<type>]<type>[]/**
* GET /hello
* @description Get a "hello world" message.
* @response {string} 200 - hello world.
*/
OpenAPI equivalent:
/hello:
get:
description: Get a "hello world" message.
responses:
200:
description: hello world.
schema:
type: string
/**
* GET /api/v1/cars/{country}/{city}
* @description Get a list of cars at a location.
* @pathParam {string} country - Country of the rental company.
* @pathParam {string} city - City of the rental company.
* @queryParam {[string]} company - Rental Company name.
* @queryParam {[string]} car - Car Name.
* @queryParam {[string]} type - Car Type.
* @queryParam {[string]} style - Car Style.
* @queryParam {[number]} mincost - Min Cost.
* @queryParam {[number]} maxcost - Max Cost.
* @response {Car[]} 200 - A list of cars.
* @response 400 - Example Error.
*/
definitions:
Car:
type: object
properties:
id:
type: string
city:
type: string
country:
type: string
name:
type: string
company:
type: string
image:
type: string
cost:
type: number
type:
type: string
style:
type: string
OpenAPI equivalent:
/api/v1/cars/{country}/{city}:
get:
description: Get a list of cars at a location.
parameters:
- in: path
name: country
description: Country of the rental company
required: true
schema:
type: string
- in: path
name: city
description: City ofthe rental company
required: true
schema:
type: string
- in: query
name: company
description: Renatal Company name
schema:
type: string
- in: query
name: car
description: Car Name
schema:
type: string
- in: query
name: type
description: Car Type
schema:
type: string
- in: query
name: style
description: Car Style
schema:
type: string
- in: query
name: mincost
description: Min Cost
schema:
type: string
- in: query
name: maxcost
description: Max Cost
schema:
type: string
responses:
200:
description: Success
schema:
type: array
items:
type: object
properties:
id:
type: string
city:
type: string
country:
type: string
name:
type: string
company:
type: string
image:
type: string
cost:
type: number
type:
type: string
style:
type: string
400:
description: Example Error
FAQs
Generates swagger doc based on JSDoc
We found that swagger-comment-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.