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

@openapi-contrib/json-schema-to-openapi-schema

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openapi-contrib/json-schema-to-openapi-schema - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

test/type-array-split.test.js

31

index.js

@@ -125,24 +125,13 @@ 'use strict';

if (Array.isArray(schema.type)) {
if (schema.type.length > 2 || !schema.type.includes('null')) {
throw new Error('Type of ' + schema.type.join(',') + ' is too confusing for OpenAPI to understand. Found in ' + JSON.stringify(schema));
if (schema.type.includes('null')) {
schema.nullable = true;
}
switch (schema.type.length) {
case 0:
delete schema.type;
break;
case 1:
if (schema.type === 'null') {
schema.nullable = true;
}
else {
schema.type = schema.type[0];
}
break;
default:
schema.type = schema.type.find(type => type !== 'null');
schema.nullable = true;
const typesWithoutNull = schema.type.filter(type => type !== 'null');
if (typesWithoutNull.length === 0) {
delete schema.type
} else if (typesWithoutNull.length === 1) {
schema.type = typesWithoutNull[0];
} else {
delete schema.type;
schema.anyOf = typesWithoutNull.map(type => ({ type }));
}

@@ -149,0 +138,0 @@ }

{
"name": "@openapi-contrib/json-schema-to-openapi-schema",
"version": "1.1.0",
"version": "1.2.0",
"description": "Converts a JSON Schema to OpenAPI Schema Object",

@@ -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