New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

openapi-json-schema

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-json-schema - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

5

dist/lib/index.d.ts

@@ -17,5 +17,4 @@ import type { JSONSchema7 } from 'json-schema';

license?: import("./types").OpenApiLicenseContact | undefined;
} | {
title: string;
version: string;
'x-id'?: string | undefined;
'x-comment'?: string | undefined;
};

@@ -22,0 +21,0 @@ paths: Record<string, unknown>;

12

dist/lib/index.js

@@ -7,5 +7,15 @@ "use strict";

function decorateOpenApi(schema, { title, version, schemaVersion = '3.0.0', }) {
const info = { title, version };
if (schema.$id) {
info['x-id'] = schema.$id;
delete schema.$id;
}
if (schema.$comment) {
info['x-comment'] = schema.$comment;
delete schema.$comment;
}
delete schema.$schema;
return {
openapi: schemaVersion,
info: { title, version },
info,
paths: {},

@@ -12,0 +22,0 @@ ...schema,

@@ -18,2 +18,6 @@ "use strict";

const decorateType = (t, type) => (type === "any" || !type) ? t : ({ ...t, type });
if (typeof schema.const !== 'undefined') {
rest.enum = [schema.const];
delete rest.const;
}
const decorateNullable = (t) => nullable ? ({ ...t, nullable }) : t;

@@ -20,0 +24,0 @@ if (Array.isArray(type)) {

@@ -11,2 +11,4 @@ import type { JSONSchema4, JSONSchema4TypeName } from 'json-schema';

license?: OpenApiLicenseContact;
'x-id'?: string;
'x-comment'?: string;
};

@@ -13,0 +15,0 @@ paths: Record<string, unknown>;

{
"name": "openapi-json-schema",
"version": "1.1.2",
"version": "1.1.3",
"description": "Minimalistic OpenAPI 3 ⬌ JSON Schema (draft 7) conversion",

@@ -5,0 +5,0 @@ "author": "Gustaf Räntilä",

@@ -15,2 +15,4 @@ [![npm version][npm-image]][npm-url]

* `$ref`'s being converted `#/definitions` <-> `#/components/schemas`
* `const` ➡ `enum` when converting to OpenAPI
* `$id`/`$comment` ➡ `info['x-id']`/`info['x-comment']` when converting to OpenAPI
* *PR's are welcome.*

@@ -17,0 +19,0 @@ * JSON `$ref`s are not resolved.

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