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 1.14.4 to 1.15.0

lib/annotations/baseUrl.js

2

cli.js

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

promises.push(
generateApiClient(endpoints.filter(e => !!e.call), config.apiClient, {
generateApiClient(endpoints, config.apiClient, {
baseUrl: config.baseUrl,

@@ -124,0 +124,0 @@ schemas,

module.exports = {
namespace: require('./namespace'),
schema: require('./schema'),
baseUrl: require('./baseUrl'),
url: require('./url'),

@@ -5,0 +6,0 @@ params: require('./params'),

@@ -15,2 +15,4 @@ const parseComments = require('./parseComments');

const mainAnnotations = ['url', 'baseUrl', 'schema'];
return Promise

@@ -22,3 +24,3 @@ .all(files.map(function (file) {

if (!list.some(item => item.name === 'url' || item.name === 'schema')) {
if (list.every(item => !mainAnnotations.includes(item.name))) {
return;

@@ -25,0 +27,0 @@ }

@@ -31,2 +31,40 @@ const fs = require('fs');

var baseUrlHash = {};
for (let {baseUrl, namespace, file} of endpoints) {
if (!baseUrl) continue;
if (baseUrlHash.hasOwnProperty(namespace)) {
let ns = file && file + '|' + namespace;
if (ns && !baseUrlHash.hasOwnProperty(ns)) {
baseUrlHash[ns] = baseUrl;
continue;
}
throw new Error(`Duplicate baseUrl ${JSON.stringify(baseUrl)}`);
}
baseUrlHash[namespace] = baseUrl;
}
if (baseUrl) {
baseUrlHash['default'] = baseUrl;
}
for (let e of endpoints) {
if (e.baseUrl) continue;
let baseUrl = (
(e.file && baseUrlHash[e.file + '|' + e.namespace]) ||
(e.namespace !== 'default' && baseUrlHash[e.namespace])
);
if (baseUrl) {
e.baseUrl = baseUrl;
}
}
endpoints = endpoints.filter(e => !!e.call);
stream.write(

@@ -46,6 +84,7 @@ mainTpl

endpoints.forEach(function (endpoint, n) {
var {parts} = endpoint.call;
var root = ns;
var last = parts.length - 1;
for (let n = 0; n < endpoints.length; n++) {
let endpoint = endpoints[n];
let {parts} = endpoint.call;
let root = ns;
let last = parts.length - 1;

@@ -59,3 +98,3 @@ parts.forEach(function (prop, i) {

});
});
}

@@ -62,0 +101,0 @@ const toString = function (indent, method, tag) {

@@ -138,3 +138,3 @@ const {pathToRegexp, compile: createToPath} = require('path-to-regexp');

const url = e.url.toPath(params);
const url = (e.baseUrl || '') + e.url.toPath(params);

@@ -141,0 +141,0 @@ const res = await Api.request({

{
"name": "api-doc-validator",
"version": "1.14.4",
"version": "1.15.0",
"description": "api doc and validator",

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

@@ -8,2 +8,3 @@ # api ➡️ doc ➡️ validator

* [@url](#url)
* [@baseUrl](#baseurl)
* [@params](#params)

@@ -50,2 +51,20 @@ * [@query](#query)

## @baseUrl
```
@baseurl path
```
```javascript
/**
* @baseUrl /v1
*/
/**
* @url /users
*/
```
Final url will be `/v1/users`
## @params

@@ -52,0 +71,0 @@

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