Socket
Socket
Sign inDemoInstall

apidoc

Package Overview
Dependencies
237
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.53.1 to 0.54.0

42

lib/core/parser.js

@@ -511,9 +511,18 @@ /*

function _sanityChecks (parsedBlocks, log, filename) {
const definedBlocksByName = {};
for (const block of parsedBlocks) {
let paramFields = [];
if (block.global.define && block.global.define.name) {
definedBlocksByName[block.global.define.name] = block;
}
}
for (const block of parsedBlocks) {
const paramFields = _paramFieldsFromBlock(block);
if (block.local.parameter && block.local.parameter.fields) {
// Loop all fields regardless of the field group. The default field group is `Parameter` but it could be provided by the developer.
for (const key in block.local.parameter.fields) {
paramFields = paramFields.concat(block.local.parameter.fields[key]);
let paramFieldsDefinedOutside = [];
if (block.local.use) {
for (const define of block.local.use) {
const definedBlock = definedBlocksByName[define.name];
if (definedBlock) {
paramFieldsDefinedOutside = paramFieldsDefinedOutside.concat(_paramFieldsFromBlock(definedBlock));
}
}

@@ -535,10 +544,12 @@ }

for (const urlParam of urlParams) {
if (!paramFields.some(pf => pf.field === urlParam)) {
if (!paramFields.some(pf => pf.field === urlParam) && !paramFieldsDefinedOutside.some(pf => pf.field === urlParam)) {
log.warn(`URL contains a parameter ':${urlParam}' that is not documented as @apiParam in @api '${block.local.title}' in file: '${filename}'`);
}
}
for (const paramField of paramFields) {
// Emit the warning only if the field is mandatory.
if (!paramField.optional && !urlParams.some(up => up === paramField.field)) {
log.warn(`@apiParam '${paramField.field}' was defined but does not appear in URL of @api '${block.local.title}' in file: '${filename}'`);
if (!block.global.define) {
for (const paramField of paramFields) {
// Emit the warning only if the field is mandatory.
if (!paramField.optional && !urlParams.some(up => up === paramField.field)) {
log.warn(`@apiParam '${paramField.field}' was defined but does not appear in URL of @api '${block.local.title}' in file: '${filename}'`);
}
}

@@ -548,1 +559,12 @@ }

}
function _paramFieldsFromBlock (block) {
let paramFields = [];
if (block.local.parameter && block.local.parameter.fields) {
// Loop all fields regardless of the field group. The default field group is `Parameter` but it could be provided by the developer.
for (const key in block.local.parameter.fields) {
paramFields = paramFields.concat(block.local.parameter.fields[key]);
}
}
return paramFields;
}

@@ -15,6 +15,7 @@ /*

class Writer {
constructor (api, app) {
constructor (api, app, cacheBustingQueryParam = `v=${Date.now()}`) {
this.api = api;
this.log = app.log;
this.opt = app.options;
this.cacheBustingQueryParam = String(cacheBustingQueryParam);
this.fs = require('fs-extra');

@@ -105,3 +106,4 @@ this.path = require('path');

let mode = 'production';
let devtool = false;
// https://webpack.js.org/configuration/devtool/ - constistent type
let devtool = '';
if (this.opt.debug) {

@@ -112,3 +114,3 @@ mode = 'development';

webpackConfig.mode = mode;
webpackConfig.devtool = devtool;
webpackConfig.devtool = devtool || false;

@@ -132,10 +134,11 @@ const compiler = webpack(webpackConfig);

const projectInfo = JSON.parse(this.api.project);
const title = projectInfo.title ?? projectInfo.name ?? 'Loading...';
const description = projectInfo.description ?? projectInfo.name ?? 'API Documentation';
const title = projectInfo.title || projectInfo.name || 'Loading...';
const description = projectInfo.description || projectInfo.name || 'API Documentation';
const indexHtml = this.fs.readFileSync(this.path.join(this.opt.template, 'index.html'), 'utf8');
return indexHtml.toString()
// replace title and description
.replace(/__API_NAME__/, title)
.replace(/__API_DESCRIPTION__/, description);
// replace titles, descriptions and cache busting query params
.replace(/__API_NAME__/g, title)
.replace(/__API_DESCRIPTION__/g, description)
.replace(/__API_CACHE_BUSTING_QUERY_PARAM__/g, this.cacheBustingQueryParam);
}

@@ -142,0 +145,0 @@

{
"name": "apidoc",
"version": "0.53.1",
"version": "0.54.0",
"description": "RESTful web API Documentation Generator",

@@ -5,0 +5,0 @@ "author": "Peter Rottmann <rottmann@inveris.de>",

@@ -143,6 +143,8 @@ /*

requestParams.processData = false;
// GET and DELETE methods do not need content-type
if (method.toLowerCase() === 'get' || method.toLowerCase() === 'delete') {
delete requestParams.headers['Content-Type'];
}
// With no content-type header, browser will know it needs to generate a proper content-type for
// the form data when sending it. Fix #1122
delete requestParams.headers['Content-Type'];
// As of jQuery 1.6 you can pass false to tell jQuery to not set any content type header.
// https://api.jquery.com/jquery.ajax/
requestParams.contentType = false;
}

@@ -149,0 +151,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc