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.20.0 to 2.21.0

68

index.d.ts
export function filesToEndpoints(files: Strings, options: Partial<CliConfig>): Promise<Endpoint[]>;
export function generateExpressMiddleware(endpoints: Endpoint[], file: string, options?: {schemas?: object} & Pick<CliConfig, 'jsdocTypedefs'>): void;
export function generateApiClient(endpoints: Endpoint[], file: string, options?: {schemas?: object} & Partial<CliConfig>): void;
export function parseComments(file: string): Promise<ParsedComment[]>;
export function parseAnnotations(comment: string, options?: Partial<CliConfig>): ParsedAnnotation[];

@@ -73,2 +75,66 @@ export type CliConfig = {

export type Schema = {[prop: string]: any};
export type Schema = {[prop: string]: any};
export type ParsedComment = {
value: string,
start: Loc,
end: Loc,
target?: ParsedCommentTarget,
array?: ParsedCommentArray,
};
export type Loc = {
line: number,
column: number,
};
export type ParsedCommentTarget = {
name: string,
var?: 'var' | 'let' | 'const',
class?: true,
async?: true,
static?: true,
function?: true,
};
export type ParsedCommentArray = string[];
export type ParsedAnnotation = {
name: AnnotationEnum,
value: AnnotationNameToValue[AnnotationEnum]
};
export enum AnnotationEnum {
NS = "ns",
Schema = "schema",
BaseUrl = "baseUrl",
Url = "url",
Params = "params",
Query = "query",
Body = "body",
File = "file",
Files = "files",
Response = "response",
Call = "call",
Description = "description",
}
export type AnnotationNameToValue = {
[AnnotationEnum.NS]: string,
[AnnotationEnum.Schema]: AnnotationSchema & {
name: string,
local: boolean,
},
[AnnotationEnum.BaseUrl]: string,
[AnnotationEnum.Url]: string,
[AnnotationEnum.Params]: AnnotationSchema,
[AnnotationEnum.Query]: AnnotationSchema,
[AnnotationEnum.Body]: AnnotationSchema,
[AnnotationEnum.File]: AnnotationSchema,
[AnnotationEnum.Files]: AnnotationSchema,
[AnnotationEnum.Response]: AnnotationSchema & {code: null | {type: 'string' | 'number'}},
[AnnotationEnum.Call]: string,
[AnnotationEnum.Description]: string,
};
type AnnotationSchema = {schema: string,};
const filesToEndpoints = require('./lib/filesToEndpoints');
const parseComments = require('./lib/parseComments');
const parseAnnotations = require('./lib/parseAnnotations');
const generateExpressMiddleware = require('./lib/generate/expressMiddleware');

@@ -7,4 +9,6 @@ const generateApiClient = require('./lib/generate/apiClient');

filesToEndpoints,
parseComments,
parseAnnotations,
generateExpressMiddleware,
generateApiClient,
};
const fs = require('fs');
const parser = require('@babel/parser');
const t = require('@babel/types');

@@ -196,3 +197,4 @@ const TEXT = 1;

list.at(-1).array = toArray(text.slice(0, end + 1));
const item = list.at(-1);
item.array = toArray(text.slice(0, end + 1), {line, column});
text = slice(text, end + 1);

@@ -229,6 +231,16 @@ state = TEXT;

function toArray(code) {
function toArray(code, loc) {
const ast = parser.parseExpression(code);
return ast.elements.map(node => node.value);
if (!t.isArrayExpression(ast)) {
const AdvSyntaxError = require('adv-parser/lib/AdvSyntaxError');
throw new AdvSyntaxError({loc}, `Invalid array syntax`);
}
return (
ast.elements
.filter(node => t.isStringLiteral(node))
.map(node => node.value)
);
}

2

package.json
{
"name": "api-doc-validator",
"version": "2.20.0",
"version": "2.21.0",
"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