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

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.14.0 to 2.15.0

index.d.ts

27

cli.js

@@ -21,2 +21,3 @@ #!/usr/bin/env node

.option('-j, --json <path>', 'generate endpoints json')
.option('-s, --export-schemas <names...>', 'generate schemas json')
.option('-n, --namespace <namespace>', 'generate validators only with this namespace or comma separated namespaces')

@@ -42,4 +43,7 @@ .option('-M, --default-method <method>', 'default @url METHOD')

let configPath = program.config;
/** @type {import('./index').CliConfig} */
const options = program.opts();
let configPath = options.config;
if (configPath) {

@@ -56,5 +60,7 @@ if (!isAbsolute(configPath)) {

const configDir = configPath ? dirname(configPath) : CWD;
/** @type {import('./index').CliConfig} */
const config = configPath ? JSON.parse(readFileSync(configPath, 'utf-8')) : {};
defaults(config, program, [
defaults(config, options, [
'include',

@@ -72,2 +78,3 @@ 'baseUrl',

'className',
'exportSchemas',
'pathToRegexp',

@@ -79,3 +86,3 @@ 'requestMethod',

resolvePath(config, program, [
resolvePath(config, options, [
'basePath',

@@ -144,3 +151,3 @@ 'apiClient',

var cache = {...defaultSchemas};
const cache = {...defaultSchemas};

@@ -160,3 +167,3 @@ filesToEndpoints(files, {...config, schemas: cache})

var schemas = {};
const schemas = {};

@@ -169,3 +176,3 @@ for (let name in cache) {

var promises = [];
const promises = [];

@@ -220,2 +227,10 @@ if (config.apiClient) {

if (config.exportSchemas) {
const generateSchemas = require('./lib/generate/schemas');
promises.push(
generateSchemas(endpoints, config.exportSchemas, configDir)
);
}
return Promise.all(promises);

@@ -222,0 +237,0 @@ })

module.exports = function (data) {
var names = Object.keys(data.schema.properties);
const names = Object.keys(data.schema.properties);

@@ -4,0 +4,0 @@ return {

const {readFileSync, createWriteStream} = require('fs');
const {resolve, dirname, relative} = require('path');
const mkdir = require('mkdirp');
const {mkdirpSync} = require('mkdirp');
const Ajv = require('ajv').default;

@@ -29,3 +29,3 @@ const ajv = new Ajv({coerceTypes: true});

mkdir.sync(outputDir);
mkdirpSync(outputDir);

@@ -32,0 +32,0 @@ const getTemplate = function (filename) {

@@ -1,8 +0,8 @@

const {readFile, writeFile} = require('fs').promises;
const {readFile, writeFile} = require('fs/promises');
const {resolve, dirname} = require('path');
const mkdir = require('mkdirp');
const {mkdirpSync} = require('mkdirp');
const ajvToJsDoc = require('../ajvToJsDoc');
module.exports = async function (endpoints, file, {schemas = {}, jsdocTypedefs = true}) {
mkdir.sync(dirname(file));
module.exports = async function (endpoints, file, {schemas = {}, jsdocTypedefs = true} = {}) {
mkdirpSync(dirname(file));

@@ -9,0 +9,0 @@ endpoints = endpoints.filter(e => !!e.url);

@@ -1,2 +0,2 @@

const {writeFile} = require('fs').promises;
const {writeFile} = require('fs/promises');

@@ -3,0 +3,0 @@ module.exports = function generateJson(endpoints, path) {

@@ -1,2 +0,2 @@

const glob = require('glob');
const {globSync} = require('glob');
const fs = require('fs');

@@ -11,3 +11,3 @@ const {join} = require('path');

return list.concat(glob.sync(path, {
return list.concat(globSync(path, {
nodir: true

@@ -14,0 +14,0 @@ }));

{
"name": "api-doc-validator",
"version": "2.14.0",
"version": "2.15.0",
"description": "api doc and validator",
"main": "index.js",
"types": "index.d.ts",
"scripts": {

@@ -33,5 +34,5 @@ "test": "mocha --ui bdd ./tests"

"adv-parser": "^2.4.1",
"commander": "^5.1.0",
"glob": "^7.2.3",
"mkdirp": "^1.0.4"
"commander": "^11.1.0",
"glob": "^10.3.10",
"mkdirp": "^3.0.1"
},

@@ -38,0 +39,0 @@ "devDependencies": {

@@ -357,20 +357,26 @@ # api ➡️ doc ➡️ validator

```
-c, --config <path> path to config json file
-i, --include <path> path to source file
-a, --api-client <path> generate api client
-d, --api-dts <path> generate api client .d.ts file
-b, --base-url <url> default Api.baseUrl
-p, --base-path <path> base path for @see filename comment
-e, --express <path> generate express middleware validator
-o, --open-api <path> generate Swagger OpenAPI v3 json
-j, --json <path> generate endpoints json
-n, --namespace <namespace> generate validators only with this namespace or comma separated namespaces
-M, --default-method <method> default @url METHOD
-C, --default-code <code> default @response CODE
-S, --default-schemas <path> path to js file with default schemas
-T, --jsdoc-methods <boolean> generate @type for methods, default true
-T, --jsdoc-typedefs <boolean> generate @typedef, default true
-R, --jsdoc-refs <boolean> use references to jsdoc @typedef or replace them with reference body, default true
-I, --include-jsdoc <boolean> include to endpoints jsdoc annotations, default false
-P, --extra-props <boolean> value for ajv "object" additionalProperties, default false
-c, --config <path> path to config json file
-i, --include <path> path to source file
-a, --api-client <path> generate api client
-d, --api-dts <path> generate api client .d.ts file
-b, --base-url <url> default Api.baseUrl
-p, --base-path <path> base path for @see filename comment
-e, --express <path> generate express middleware validator
-o, --open-api <path> generate Swagger OpenAPI v3 json
-j, --json <path> generate endpoints json
-s, --export-schemas <names...> generate schemas json
-n, --namespace <namespace> generate validators only with this namespace or comma separated namespaces
-M, --default-method <method> default @url METHOD
-C, --default-code <code> default @response CODE
-S, --default-schemas <path...> path to js file with default schemas
-J, --jsdoc-methods <boolean> generate methods @type, default true
-T, --jsdoc-typedefs <boolean> generate @typedef, default true
-R, --jsdoc-refs <boolean> use references to jsdoc @typedef or replace them with reference body, default true
-I, --include-jsdoc <boolean> include to endpoints standard jsdoc annotations, default false
-P, --extra-props <boolean> value for ajv "object" additionalProperties, default false
-N, --class-name <string> name of generated api client class, default "Api"
--path-to-regexp <boolean> whether to add a path-to-regexp support, default true
--request-method <boolean> whether to add a Api.request method, default true
--get-ajv-method <boolean> whether to add a Api.getAjv method, default true
--error-handler-method <boolean> whether to add a Api.errorHandler method, default true
```

@@ -562,2 +568,4 @@

* `json` same as `--json <path>`
* `exportSchemas` array of schemas names to be saved as json. Could be empty array then will be exported all schemas.
Last item of this array could be path to json file, if no path then formatted json will output to console
* `express` same as `--express <path>`

@@ -564,0 +572,0 @@ * `openApi` same as `--open-api <path>`

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