koas-core
Advanced tools
Comparing version 0.5.5 to 0.6.0
@@ -44,8 +44,8 @@ "use strict"; | ||
function koas(document, middlewares = [], { onSchemaValidationError = (error) => ({ message: error.message, errors: error.result.errors }), } = {}) { | ||
const resolveRef = jsonRefs_1.createResolver(document); | ||
const resolveRef = (0, jsonRefs_1.createResolver)(document); | ||
const matchers = Object.entries(document.paths).map(([pathTemplate, pathItemObject]) => { | ||
const matcher = matcher_1.createMatcher(pathTemplate, resolveRef, pathItemObject.parameters); | ||
const matcher = (0, matcher_1.createMatcher)(pathTemplate, resolveRef, pathItemObject.parameters); | ||
return [matcher, pathItemObject]; | ||
}); | ||
const validator = validation_1.createValidator(document); | ||
const validator = (0, validation_1.createValidator)(document); | ||
const validate = (instance, schema, { message = 'JSON schema validation failed', preValidateProperty, rewrite, status, throw: throwError = true, } = {}) => { | ||
@@ -52,0 +52,0 @@ const result = validator.validate(instance, schema, { |
@@ -53,7 +53,7 @@ "use strict"; | ||
if (typeof $ref !== 'string') { | ||
throw new TypeError(`Invalid JSON pointer. Expected a string. Got: ${util_1.inspect($ref)}`); | ||
throw new TypeError(`Invalid JSON pointer. Expected a string. Got: ${(0, util_1.inspect)($ref)}`); | ||
} | ||
if (stack.includes($ref)) { | ||
throw new Error(`Circular JSON reference found: ${stack | ||
.map((frame) => util_1.inspect(frame)) | ||
.map((frame) => (0, util_1.inspect)(frame)) | ||
.concat($ref) | ||
@@ -67,3 +67,3 @@ .join(' → ')}`); | ||
if (hashtag !== '#') { | ||
throw new TypeError(`Invalid JSON pointer. It should start with '#/'. Got: ${util_1.inspect($ref)}`); | ||
throw new TypeError(`Invalid JSON pointer. It should start with '#/'. Got: ${(0, util_1.inspect)($ref)}`); | ||
} | ||
@@ -75,3 +75,3 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} | ||
throw new Error(`Unresolved JSON pointer: ${util_1.inspect($ref)}. Property ${util_1.inspect(name)} could not be resolved.`); | ||
throw new Error(`Unresolved JSON pointer: ${(0, util_1.inspect)($ref)}. Property ${(0, util_1.inspect)(name)} could not be resolved.`); | ||
}, document); | ||
@@ -78,0 +78,0 @@ const dereferenced = resolver(result, [...stack, $ref]); |
@@ -58,3 +58,3 @@ "use strict"; | ||
if ('schema' in wrapper) { | ||
validator.addSchema(wrapper.schema, `${prefix}/${jsonRefs_1.escapeJsonPointer(key)}/schema`); | ||
validator.addSchema(wrapper.schema, `${prefix}/${(0, jsonRefs_1.escapeJsonPointer)(key)}/schema`); | ||
} | ||
@@ -64,3 +64,3 @@ }); | ||
iter(components.schemas, (key, schema) => { | ||
validator.addSchema(schema, `#/components/schemas/${jsonRefs_1.escapeJsonPointer(key)}`); | ||
validator.addSchema(schema, `#/components/schemas/${(0, jsonRefs_1.escapeJsonPointer)(key)}`); | ||
}); | ||
@@ -71,3 +71,3 @@ procesSchemaWrapper(components.headers, '#/components/headers'); | ||
if ('content' in requestBody) { | ||
procesSchemaWrapper(requestBody.content, `#/components/requestBodies/${jsonRefs_1.escapeJsonPointer(key)}/content`); | ||
procesSchemaWrapper(requestBody.content, `#/components/requestBodies/${(0, jsonRefs_1.escapeJsonPointer)(key)}/content`); | ||
} | ||
@@ -77,6 +77,6 @@ }); | ||
if ('headers' in response) { | ||
procesSchemaWrapper(response.headers, `#/components/responses/${jsonRefs_1.escapeJsonPointer(key)}/headers`); | ||
procesSchemaWrapper(response.headers, `#/components/responses/${(0, jsonRefs_1.escapeJsonPointer)(key)}/headers`); | ||
} | ||
if ('content' in response) { | ||
procesSchemaWrapper(response.content, `#/components/responses/${jsonRefs_1.escapeJsonPointer(key)}/content`); | ||
procesSchemaWrapper(response.content, `#/components/responses/${(0, jsonRefs_1.escapeJsonPointer)(key)}/content`); | ||
} | ||
@@ -83,0 +83,0 @@ }); |
{ | ||
"name": "koas-core", | ||
"version": "0.5.5", | ||
"version": "0.6.0", | ||
"keywords": [ | ||
@@ -32,3 +32,3 @@ "koa", | ||
"koa-compose": "^4.0.0", | ||
"openapi-types": "^10.0.0" | ||
"openapi-types": "^11.0.0" | ||
}, | ||
@@ -42,4 +42,4 @@ "devDependencies": { | ||
"engines": { | ||
"node": ">=12.0.0" | ||
"node": ">=14" | ||
} | ||
} |
20395
+ Addedopenapi-types@11.1.0(transitive)
- Removedopenapi-types@10.0.0(transitive)
Updatedopenapi-types@^11.0.0