Socket
Socket
Sign inDemoInstall

api-doc-validator

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-doc-validator - npm Package Compare versions

Comparing version 2.7.2 to 2.7.3

22

lib/ajvToJsDoc.js

@@ -6,7 +6,13 @@ module.exports = ajvToJsDoc;

function ajvToJsDoc(schema, params = {}) {
const {schemas = {}, any = '*', jsDocNull = true, anyObject = 'Object'} = params;
const {schemas = {}, any = '*', jsDocNull = true, anyObject = 'Object', usedSchemas} = params;
const {type, title} = schema;
if (schemas.hasOwnProperty(title)) return normalizeName(title);
if (schemas.hasOwnProperty(title)) {
if (usedSchemas && !usedSchemas.includes(title)) {
usedSchemas.push(title);
}
return normalizeName(title);
}
if (type === 'string' || type === 'number') {

@@ -61,3 +67,13 @@ if (!schema.enum) return type;

if (anyOf || allOf) {
return (anyOf || allOf).map(item => ajvToJsDoc(item, params)).join('|');
const list = [];
for (const item of (anyOf || allOf)) {
const schema = ajvToJsDoc(item, params);
if (list.includes(schema)) continue;
list.push(schema);
}
return list.join('|');
}

@@ -64,0 +80,0 @@

11

lib/generate/apiClient.js

@@ -55,3 +55,2 @@ const {readFileSync, createWriteStream} = require('fs');

const dtsStream = dtsFile && createWriteStream(dtsFile);
const dtsParams = {any: 'any'}

@@ -156,3 +155,5 @@ const p = Promise.all([

const methodBase = (params) => createMethod({outputDir, endpoints, schemas, ...params});
const usedSchemas = [];
const methodBase = (params) => createMethod({outputDir, endpoints, schemas, usedSchemas, ...params});
const methodJs = (method, tag, indent = 1) => methodBase({tpl: methodTpl, method, tag, indent, generator: ajvToJsDoc});

@@ -200,3 +201,3 @@ const methodDts = (method, tag, indent = 1) => methodBase({tpl: `method = (params) => Promise<*>`, indent, method, tag, generator: ajvToDTs, any: 'any'});

for (let name in schemas) {
for (let name of usedSchemas) {
const schema = ajvToDTs(schemas[name]);

@@ -257,6 +258,6 @@ name = normalizeName(name);

function createMethod({tpl, endpoints, outputDir, indent, method, tag, schemas, generator, any = '*'}) {
function createMethod({tpl, endpoints, outputDir, indent, method, tag, schemas, generator, usedSchemas, any = '*'}) {
const n = tag.match(/\d+$/)[0];
const e = endpoints[n];
const jsDoc = (schema) => generator(schema, {schemas, any});
const jsDoc = (schema) => generator(schema, {schemas, any, usedSchemas});

@@ -263,0 +264,0 @@

{
"name": "api-doc-validator",
"version": "2.7.2",
"version": "2.7.3",
"description": "api doc and validator",

@@ -5,0 +5,0 @@ "main": "index.js",

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