@aws-cdk/cloud-assembly-schema
Advanced tools
Comparing version 39.1.39 to 39.1.40
@@ -252,3 +252,3 @@ "use strict"; | ||
_a = JSII_RTTI_SYMBOL_1; | ||
Manifest[_a] = { fqn: "@aws-cdk/cloud-assembly-schema.Manifest", version: "39.1.39" }; | ||
Manifest[_a] = { fqn: "@aws-cdk/cloud-assembly-schema.Manifest", version: "39.1.40" }; | ||
function mapValues(xs, fn) { | ||
@@ -255,0 +255,0 @@ if (!xs) { |
'use strict'; | ||
var uri = require('url'); | ||
var ValidationError = exports.ValidationError = function ValidationError (message, instance, schema, path, name, argument) { | ||
@@ -85,3 +87,3 @@ if(Array.isArray(path)){ | ||
function ValidatorResultError(result) { | ||
if(typeof Error.captureStackTrace === 'function'){ | ||
if(Error.captureStackTrace){ | ||
Error.captureStackTrace(this, ValidatorResultError); | ||
@@ -107,5 +109,3 @@ } | ||
Error.call(this, msg); | ||
if(typeof Error.captureStackTrace === 'function'){ | ||
Error.captureStackTrace(this, SchemaError); | ||
} | ||
Error.captureStackTrace(this, SchemaError); | ||
}; | ||
@@ -134,3 +134,3 @@ SchemaError.prototype = Object.create(Error.prototype, | ||
SchemaContext.prototype.resolve = function resolve (target) { | ||
return (() => resolveUrl(this.base,target))(); | ||
return uri.resolve(this.base, target); | ||
}; | ||
@@ -141,3 +141,3 @@ | ||
var id = schema.$id || schema.id; | ||
let base = (() => resolveUrl(this.base,id||''))(); | ||
var base = uri.resolve(this.base, id||''); | ||
var ctx = new SchemaContext(schema, this.options, path, base, Object.create(this.schemas)); | ||
@@ -395,17 +395,1 @@ if(id && !ctx.schemas[base]){ | ||
/** | ||
* Resolve target URL from a base and relative URL. | ||
* Similar to Node's URL Lib's legacy resolve function. | ||
* Code from example in deprecation note in said library. | ||
* @param string | ||
* @param string | ||
* @returns {string} | ||
*/ | ||
var resolveUrl = exports.resolveUrl = function resolveUrl(from, to) { | ||
const resolvedUrl = new URL(to, new URL(from, 'resolve://')); | ||
if (resolvedUrl.protocol === 'resolve:') { | ||
const { pathname, search, hash } = resolvedUrl; | ||
return pathname + search + hash; | ||
} | ||
return resolvedUrl.toString(); | ||
} |
@@ -30,9 +30,2 @@ /* | ||
export declare class ValidatorResultError extends Error { | ||
instance: any; | ||
schema: Schema; | ||
options: Options; | ||
errors: ValidationError; | ||
} | ||
export declare class ValidationError { | ||
@@ -76,3 +69,2 @@ constructor(message?: string, instance?: any, schema?: Schema, propertyPath?: any, name?: string, argument?: any); | ||
items?: Schema | Schema[] | ||
contains?: Schema | ||
maxItems?: number | ||
@@ -84,3 +76,2 @@ minItems?: number | ||
required?: string[] | boolean | ||
propertyNames?: boolean | Schema | ||
additionalProperties?: boolean | Schema | ||
@@ -110,4 +101,2 @@ definitions?: { | ||
else?: Schema | ||
default?: any | ||
examples?: any[] | ||
} | ||
@@ -114,0 +103,0 @@ |
"use strict"; | ||
var urilib = require('url'); | ||
var helpers = require('./helpers'); | ||
@@ -22,3 +23,3 @@ | ||
if(schema.$ref){ | ||
let resolvedUri = helpers.resolveUrl(baseuri,schema.$ref); | ||
var resolvedUri = urilib.resolve(baseuri, schema.$ref); | ||
ref[resolvedUri] = ref[resolvedUri] ? ref[resolvedUri]+1 : 0; | ||
@@ -28,4 +29,3 @@ return; | ||
var id = schema.$id || schema.id; | ||
let resolvedBase = helpers.resolveUrl(baseuri,id); | ||
var ourBase = id ? resolvedBase : baseuri; | ||
var ourBase = id ? urilib.resolve(baseuri, id) : baseuri; | ||
if (ourBase) { | ||
@@ -32,0 +32,0 @@ // If there's no fragment, append an empty one |
'use strict'; | ||
var urilib = require('url'); | ||
var attribute = require('./attribute'); | ||
@@ -116,3 +118,3 @@ var helpers = require('./helpers'); | ||
var id = schema.$id || schema.id; | ||
let base = helpers.resolveUrl(options.base,id||''); | ||
var base = urilib.resolve(options.base||anonymousBase, id||''); | ||
if(!ctx){ | ||
@@ -264,4 +266,4 @@ ctx = new SchemaContext(schema, options, [], base, Object.create(this.schemas)); | ||
// Else try walking the property pointer | ||
let parsed = new URL(switchSchema,'thismessage::/'); | ||
let fragment = parsed.hash; | ||
var parsed = urilib.parse(switchSchema); | ||
var fragment = parsed && parsed.hash; | ||
var document = fragment && fragment.length && switchSchema.substr(0, switchSchema.length - fragment.length); | ||
@@ -268,0 +270,0 @@ if (!document || !ctx.schemas[document]) { |
{ | ||
"author": "Tom de Grunt <tom@degrunt.nl>", | ||
"name": "jsonschema", | ||
"version": "1.5.0", | ||
"version": "1.4.1", | ||
"license": "MIT", | ||
@@ -42,2 +42,2 @@ "dependencies": {}, | ||
} | ||
} | ||
} |
@@ -83,4 +83,2 @@ [![Build Status](https://secure.travis-ci.org/tdegrunt/jsonschema.svg)](http://travis-ci.org/tdegrunt/jsonschema) | ||
``` | ||
Returned ValidatorResult object, will show this example is NOT valid since: `"votes": "lots"` is not an integer. | ||
### Example for Array schema | ||
@@ -274,31 +272,3 @@ | ||
``` | ||
### Disallowing unknown attributes | ||
Sometimes you may want to disallow unknown attributes passed in the body of the request, in order to disallow those unknown attributes before the validation of the body, you need to set additionalProperties to false. | ||
```javascript | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"title": "Accounting Resource - Add Item", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"itemNumber": { | ||
"type":"string" | ||
}, | ||
"title": { | ||
"type":"string" | ||
}, | ||
"description": { | ||
"type":"string" | ||
} | ||
}, | ||
"required": [ | ||
"itemNumber", | ||
"title", | ||
"description" | ||
] | ||
} | ||
``` | ||
### Default base URI | ||
@@ -305,0 +275,0 @@ |
@@ -69,3 +69,3 @@ { | ||
"dependencies": { | ||
"jsonschema": "^1.5.0", | ||
"jsonschema": "~1.4.1", | ||
"semver": "^7.6.3" | ||
@@ -84,3 +84,3 @@ }, | ||
"homepage": "https://github.com/cdklabs/cloud-assembly-schema", | ||
"version": "39.1.39", | ||
"version": "39.1.40", | ||
"types": "lib/index.d.ts", | ||
@@ -87,0 +87,0 @@ "stability": "stable", |
Sorry, the diff of this file is not supported yet
631229
8254
Updatedjsonschema@~1.4.1