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

core-types-json-schema

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

core-types-json-schema - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

6

dist/lib/annotations.js

@@ -27,6 +27,6 @@ "use strict";

...(jsonSchema.default
? { default: core_types_1.stringify(jsonSchema.default) }
? { default: (0, core_types_1.stringify)(jsonSchema.default) }
: {}),
...(jsonSchema.examples
? { examples: core_types_1.stringify(jsonSchema.examples) }
? { examples: (0, core_types_1.stringify)(jsonSchema.examples) }
: {}),

@@ -43,3 +43,3 @@ ...(jsonSchema.$comment

function mergeDescriptionAndSee(description, see) {
const seeAsString = () => core_types_1.ensureArray(see)
const seeAsString = () => (0, core_types_1.ensureArray)(see)
.map(see => `@see ${see}`)

@@ -46,0 +46,0 @@ .join("\n");

@@ -49,3 +49,3 @@ "use strict";

const anyOf = node.or.map(subNode => toJsonSchema(subNode));
const ret = annotations_1.annotateJsonSchema(node, { anyOf });
const ret = (0, annotations_1.annotateJsonSchema)(node, { anyOf });
if (anyOf.length > 1 && !anyOf.some(n => !isOnlyType(n))) {

@@ -59,15 +59,15 @@ delete ret.anyOf;

if (node.type === 'any')
return annotations_1.annotateJsonSchema(node, constEnum(node, {}));
return (0, annotations_1.annotateJsonSchema)(node, constEnum(node, {}));
else if (node.type === 'null')
return annotations_1.annotateJsonSchema(node, { type: 'null' });
return (0, annotations_1.annotateJsonSchema)(node, { type: 'null' });
else if (node.type === 'boolean')
return annotations_1.annotateJsonSchema(node, constEnum(node, { type: 'boolean' }));
return (0, annotations_1.annotateJsonSchema)(node, constEnum(node, { type: 'boolean' }));
else if (node.type === 'string')
return annotations_1.annotateJsonSchema(node, constEnum(node, { type: 'string' }));
return (0, annotations_1.annotateJsonSchema)(node, constEnum(node, { type: 'string' }));
else if (node.type === 'number')
return annotations_1.annotateJsonSchema(node, constEnum(node, { type: 'number' }));
return (0, annotations_1.annotateJsonSchema)(node, constEnum(node, { type: 'number' }));
else if (node.type === 'integer')
return annotations_1.annotateJsonSchema(node, constEnum(node, { type: 'integer' }));
return (0, annotations_1.annotateJsonSchema)(node, constEnum(node, { type: 'integer' }));
else if (node.type === 'and')
return annotations_1.annotateJsonSchema(node, {
return (0, annotations_1.annotateJsonSchema)(node, {
allOf: node.and.map(subNode => toJsonSchema(subNode)),

@@ -83,3 +83,3 @@ });

.map(prop => [prop, toJsonSchema(node.properties[prop].node)]));
return annotations_1.annotateJsonSchema(node, constEnum(node, {
return (0, annotations_1.annotateJsonSchema)(node, constEnum(node, {
type: 'object',

@@ -98,3 +98,3 @@ ...(allKeys.length > 0 ? { properties } : {}),

else if (node.type === 'array')
return annotations_1.annotateJsonSchema(node, constEnum(node, {
return (0, annotations_1.annotateJsonSchema)(node, constEnum(node, {
type: 'array',

@@ -104,3 +104,3 @@ items: toJsonSchema(node.elementType),

else if (node.type === 'tuple')
return annotations_1.annotateJsonSchema(node, constEnum(node, {
return (0, annotations_1.annotateJsonSchema)(node, constEnum(node, {
type: 'array',

@@ -116,4 +116,4 @@ items: node.elementTypes.map(item => toJsonSchema(item)),

else if (node.type === 'ref')
return annotations_1.annotateJsonSchema(node, constEnum(node, {
$ref: openapi_json_schema_1.encodeRefNameJsonSchema(node.ref),
return (0, annotations_1.annotateJsonSchema)(node, constEnum(node, {
$ref: (0, openapi_json_schema_1.encodeRefNameJsonSchema)(node.ref),
}));

@@ -120,0 +120,0 @@ else

@@ -11,4 +11,4 @@ "use strict";

const parsed = typeof schema === 'string'
? jsonpos_1.getAstByString(schema)
: jsonpos_1.getAstByObject(schema);
? (0, jsonpos_1.getAstByString)(schema)
: (0, jsonpos_1.getAstByObject)(schema);
const { json } = parsed;

@@ -26,3 +26,3 @@ const { definitions } = json;

path: this.path,
loc: jsonpos_1.getLocation(parsed, { dataPath: this.path, markIdentifier: true }),
loc: (0, jsonpos_1.getLocation)(parsed, { dataPath: this.path, markIdentifier: true }),
};

@@ -36,3 +36,3 @@ },

if (!meta.loc)
meta.loc = jsonpos_1.getLocation(parsed, { dataPath: this.path, markIdentifier: true });
meta.loc = (0, jsonpos_1.getLocation)(parsed, { dataPath: this.path, markIdentifier: true });
throw new core_types_1.UnsupportedError(message, meta);

@@ -85,3 +85,3 @@ }

var _a, _b, _c, _d, _e;
const isOnlyOrSame = (a, b) => !(a && b && !core_types_1.isEqual(a, b));
const isOnlyOrSame = (a, b) => !(a && b && !(0, core_types_1.isEqual)(a, b));
if (!isOnlyOrSame($ref, subSchema.$ref))

@@ -99,3 +99,3 @@ ctx.throwUnsupportedError(`Cannot have $ref in a node *and* in its '${container}'`, {

else {
const newEnum = core_types_1.intersection(_enum, subSchema.enum);
const newEnum = (0, core_types_1.intersection)(_enum, subSchema.enum);
if (newEnum.length === 0)

@@ -113,3 +113,3 @@ throw new core_types_1.MalformedTypeError("Cannot merge types with non-intersecting enums", {

if (subSchema.const !== undefined) {
if (core_types_1.isEqual(_const, subSchema.const))
if ((0, core_types_1.isEqual)(_const, subSchema.const))
throw new core_types_1.MalformedTypeError("Cannot merge types with mismatching const", {

@@ -130,3 +130,3 @@ path: ctx.path,

subSchema.required =
core_types_1.union((_c = subSchema.required) !== null && _c !== void 0 ? _c : [], required !== null && required !== void 0 ? required : []);
(0, core_types_1.union)((_c = subSchema.required) !== null && _c !== void 0 ? _c : [], required !== null && required !== void 0 ? required : []);
if ((typeof properties === 'undefined') !==

@@ -141,3 +141,3 @@ (typeof subSchema.properties === 'undefined'))

const keysB = Object.keys(propB);
const combinedKeys = core_types_1.union(keysA, keysB);
const combinedKeys = (0, core_types_1.union)(keysA, keysB);
const ret = {};

@@ -245,3 +245,3 @@ combinedKeys.forEach(key => {

ctx.throwUnsupportedError(`Internal error`, { blob: { schema } });
const makeRefType = (ref) => ({ type: 'ref', ref: openapi_json_schema_1.decodeRefNameJsonSchema(ref) });
const makeRefType = (ref) => ({ type: 'ref', ref: (0, openapi_json_schema_1.decodeRefNameJsonSchema)(ref) });
const wrapRefType = (node) => schema.$ref === undefined

@@ -264,3 +264,3 @@ ? node

}
const types = core_types_1.ensureArray(schema.type)
const types = (0, core_types_1.ensureArray)(schema.type)
.map(type => fromSchemaAndType(schema, type, constEnum, ctx));

@@ -275,9 +275,9 @@ if (types.length === 1)

if (type === 'null')
return annotations_1.annotateCoreTypes({ type: 'null' }, schema);
return (0, annotations_1.annotateCoreTypes)({ type: 'null' }, schema);
else
return annotations_1.annotateCoreTypes({ type, ...constEnum }, schema);
return (0, annotations_1.annotateCoreTypes)({ type, ...constEnum }, schema);
}
else if (type === 'array') {
if (Array.isArray(schema.items)) {
return annotations_1.annotateCoreTypes({
return (0, annotations_1.annotateCoreTypes)({
type: 'tuple',

@@ -295,3 +295,3 @@ elementTypes: schema.items.map(item => fromSchema(item, walkDown(ctx, 'items'))),

else if (schema.items === false) {
return annotations_1.annotateCoreTypes({
return (0, annotations_1.annotateCoreTypes)({
type: 'tuple',

@@ -305,3 +305,3 @@ elementTypes: [],

else {
return annotations_1.annotateCoreTypes({
return (0, annotations_1.annotateCoreTypes)({
type: 'array',

@@ -318,3 +318,3 @@ elementType: (typeof schema.items === 'undefined' ||

const required = new Set((_b = schema.required) !== null && _b !== void 0 ? _b : []);
return annotations_1.annotateCoreTypes({
return (0, annotations_1.annotateCoreTypes)({
type: 'object',

@@ -321,0 +321,0 @@ properties: Object.fromEntries(Object.entries((_c = schema.properties) !== null && _c !== void 0 ? _c : {})

@@ -8,6 +8,6 @@ "use strict";

function convertCoreTypesToOpenApi(doc, options) {
const { data: jsonSchema, ...rest } = core_types_to_json_schema_1.convertCoreTypesToJsonSchema(doc, options);
const { data: jsonSchema, ...rest } = (0, core_types_to_json_schema_1.convertCoreTypesToJsonSchema)(doc, options);
return {
...rest,
data: openapi_json_schema_1.jsonSchemaDocumentToOpenApi(jsonSchema, options)
data: (0, openapi_json_schema_1.jsonSchemaDocumentToOpenApi)(jsonSchema, options)
};

@@ -20,5 +20,5 @@ }

schema = typeof schema === 'string' ? JSON.parse(schema) : schema;
const jsonSchema = openapi_json_schema_1.openApiToJsonSchema(schema);
return json_schema_to_core_types_1.convertJsonSchemaToCoreTypes(jsonSchema);
const jsonSchema = (0, openapi_json_schema_1.openApiToJsonSchema)(schema);
return (0, json_schema_to_core_types_1.convertJsonSchemaToCoreTypes)(jsonSchema);
}
exports.convertOpenApiToCoreTypes = convertOpenApiToCoreTypes;
{
"name": "core-types-json-schema",
"version": "1.5.0",
"version": "1.5.1",
"description": "core-types ⬌ JSON Schema conversion",

@@ -39,14 +39,14 @@ "author": "Gustaf Räntilä",

"dependencies": {
"@types/json-schema": "^7.0.7",
"core-types": "^1.6.0",
"@types/json-schema": "^7.0.9",
"core-types": "^1.8.2",
"jsonpos": "^1.1.0",
"openapi-json-schema": "^1.1.1"
"openapi-json-schema": "^1.1.2"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"@types/jest": "^27.0.1",
"cz-conventional-changelog": "^3.3.0",
"jest": "^26.6.3",
"jest": "^27.1.1",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.1",
"typescript": "^4.1.5"
"ts-jest": "^27.0.5",
"typescript": "^4.4.3"
},

@@ -53,0 +53,0 @@ "config": {

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