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

flair-doc

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flair-doc - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

test/joi-types-test.js

51

index.js

@@ -15,2 +15,3 @@ var express = require('express')

exports.jsonBodyParser = jsonBodyParser;
exports.joi = joi;

@@ -221,2 +222,16 @@ function api(options, routes) {

function minOrMax(swagger, joiType, index, minOrMax) {
swagger.allowableValues = swagger.allowableValues || {};
swagger.allowableValues.valueType = "RANGE";
swagger.allowableValues[minOrMax] = joiType.__args[index][0];
}
var converters = {
"float": function(swagger) { swagger.dataType = "double"; },
"integer": function(swagger) { swagger.dataType = "int"; },
"date": function(swagger) { swagger.dataType = "Date"; },
"min": minOrMax,
"max": minOrMax
};
function convertJoiTypesToSwagger(schema) {

@@ -227,12 +242,38 @@ var params = [];

, swaggerParam = {
paramType: joiType.notes || "query",
paramType: (typeof joiType.notes == 'string' ? joiType.notes : "query"),
name: param,
description: joiType.description
description: (typeof joiType.description == 'string' ? joiType.description : "")
};
if (joiType.__checks.indexOf('integer') >= 0) {
swaggerParam.dataType = "integer";
if (joiType.type === "String") {
swaggerParam.dataType = "string";
}
if (joiType.notes && joiType.notes === "path") {
if (joiType.type === "Boolean") {
swaggerParam.dataType = "boolean";
}
joiType.__checks.forEach(function(check, index) {
if (converters[check]) {
converters[check](swaggerParam, joiType, index, check);
}
});
if (joiType.__valids._values.indexOf(undefined) > -1) {
swaggerParam.required = false;
}
joiType.__valids._values.forEach(function(validValue) {
if (validValue !== undefined) {
swaggerParam.allowableValues = swaggerParam.allowableValues || {};
swaggerParam.allowableValues.valueType = "LIST";
swaggerParam.allowableValues.values = swaggerParam.allowableValues.values || [];
swaggerParam.allowableValues.values.push(validValue);
}
});
swaggerParam.required = (joiType.__modifiers._values.indexOf("required") > -1);
if (swaggerParam.paramType !== "query") {
swaggerParam.required = true;

@@ -239,0 +280,0 @@ swaggerParam.allowMultiple = false;

2

package.json
{
"name": "flair-doc",
"version": "0.0.3",
"version": "0.0.4",
"description": "Swagger-compliant REST API documentation generator",

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

@@ -228,3 +228,3 @@ var should = require('should')

description: "pant id",
dataType: "integer",
dataType: "int",
required: true,

@@ -231,0 +231,0 @@ allowMultiple: false

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