Socket
Socket
Sign inDemoInstall

json-schema-to-typescript

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-to-typescript - npm Package Compare versions

Comparing version 5.4.0 to 5.5.0

16

dist/src/parser.js

@@ -228,3 +228,8 @@ "use strict";

}); });
if ('patternProperties' in schema) {
var singlePatternProperty = false;
if (schema.patternProperties) {
// partially support patternProperties. in the case that
// additionalProperties is not set, and there is only a single
// value definition, we can validate against that.
singlePatternProperty = (!schema.additionalProperties && Object.keys(schema.patternProperties).length === 1);
asts = asts.concat(lodash_1.map(schema.patternProperties, function (value, key) {

@@ -236,6 +241,6 @@ var ast = parse(value, options, rootSchema, key, true, processed, usedNames);

ast: ast,
isPatternProperty: true,
isRequired: lodash_1.includes(schema.required || [], key),
isPatternProperty: !singlePatternProperty,
isRequired: singlePatternProperty || lodash_1.includes(schema.required || [], key),
isUnreachableDefinition: false,
keyName: key
keyName: singlePatternProperty ? '[k: string]' : key
});

@@ -262,2 +267,5 @@ }));

case true:
if (singlePatternProperty) {
return asts;
}
return asts.concat({

@@ -264,0 +272,0 @@ ast: AST_1.T_ANY_ADDITIONAL_PROPERTIES,

{
"name": "json-schema-to-typescript",
"version": "5.4.0",
"version": "5.5.0",
"description": "compile json schema to typescript typings",

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

@@ -150,2 +150,3 @@ # json-schema-to-typescript [![Build Status][build]](https://circleci.com/gh/bcherny/json-schema-to-typescript) [![npm]](https://www.npmjs.com/package/json-schema-to-typescript) [![mit]](https://opensource.org/licenses/MIT)

- [x] `additionalProperties` of type
- [x] `patternProperties` (partial support)
- [x] [`extends`](https://github.com/json-schema/json-schema/wiki/Extends)

@@ -172,3 +173,2 @@ - [x] `required` properties on objects ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L130))

- `pattern` ([string](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L203), [regex](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L207))
- `patternProperties` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L97))
- `uniqueItems` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L172))

@@ -175,0 +175,0 @@

@@ -287,3 +287,12 @@ import { whiteBright } from 'cli-color'

if ('patternProperties' in schema) {
let singlePatternProperty = false
if (schema.patternProperties) {
// partially support patternProperties. in the case that
// additionalProperties is not set, and there is only a single
// value definition, we can validate against that.
singlePatternProperty = (
!schema.additionalProperties && Object.keys(schema.patternProperties).length === 1
)
asts = asts.concat(map(schema.patternProperties, (value, key: string) => {

@@ -296,6 +305,6 @@ let ast = parse(value, options, rootSchema, key, true, processed, usedNames)

ast,
isPatternProperty: true,
isRequired: includes(schema.required || [], key),
isPatternProperty: !singlePatternProperty,
isRequired: singlePatternProperty || includes(schema.required || [], key),
isUnreachableDefinition: false,
keyName: key
keyName: singlePatternProperty ? '[k: string]' : key
})

@@ -325,2 +334,5 @@ }))

case true:
if (singlePatternProperty) {
return asts
}
return asts.concat({

@@ -327,0 +339,0 @@ ast: T_ANY_ADDITIONAL_PROPERTIES,

Sorry, the diff of this file is too big to display

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