Releases: mulesoft-labs/osprey-method-handler
Rewrote to work with webapi-parser
Major changes:
- Rewrote to work with webapi-parser (#61);
- New dependency:
webapi-parser
; - Dropped dependencies: json-schema-compatibility, is-stream, object-values, raml-validate;
- Dropped option:
RAMLVersion
(now inferred automatically); - Default exported function API changed: It now accepts
webapi-parser.Operation
object as first argument, path string as second argument, method name as third and options object as final argument; - Changed errors format;
Minor changes:
- Updated dependencies' versions;
- Switched to
const/let
instead ofvar
;
Error format change
The new version changes the errors response format for RAML and JSON Schema validation errors. The new errors responses are more uniformal and descriptive while at the same time being less verbose. The change is caused by the fact that a different parser is used to parse RAML specs, which in turn produces a different parsed document model.
Let's explore the changes on body validation examples.
JSON Schema validation example responses
Number value is greater than the "maximum":
Old:
{
"errors":[
{
"type":"json",
"keyword":"schema",
"schema":"{\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"type\": \"object\",\n \"minProperties\": 2,\n \"properties\": {\n \"firstName\": {\n \"type\": \"string\"\n },\n \"lastName\": {\n \"type\": \"string\"\n },\n \"age\": {\n \"type\": \"number\",\n \"minimum\": 5,\n \"maximum\": 99\n }\n }\n}",
"data":{
"firstName":"John",
"age":200
},
"message":"invalid json (schema, {\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"type\": \"object\",\n \"minProperties\": 2,\n \"properties\": {\n \"firstName\": {\n \"type\": \"string\"\n },\n \"lastName\": {\n \"type\": \"string\"\n },\n \"age\": {\n \"type\": \"number\",\n \"minimum\": 5,\n \"maximum\": 99\n }\n }\n})"
}
],
"stack":"..."
}
New:
{
"errors":[
{
"type":"json",
"keyword":"maximum",
"dataPath":"/age",
"message":"should be <= 99",
"data":200,
"schema":99
}
],
"stack":"..."
}
Less properties than "minProperties":
Old:
{
"errors":[
{
"type":"json",
"keyword":"schema",
"schema":"{\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"type\": \"object\",\n \"minProperties\": 2,\n \"properties\": {\n \"firstName\": {\n \"type\": \"string\"\n },\n \"lastName\": {\n \"type\": \"string\"\n },\n \"age\": {\n \"type\": \"number\",\n \"minimum\": 5,\n \"maximum\": 99\n }\n }\n}",
"data":{
"firstName":"John"
},
"message":"invalid json (schema, {\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"type\": \"object\",\n \"minProperties\": 2,\n \"properties\": {\n \"firstName\": {\n \"type\": \"string\"\n },\n \"lastName\": {\n \"type\": \"string\"\n },\n \"age\": {\n \"type\": \"number\",\n \"minimum\": 5,\n \"maximum\": 99\n }\n }\n})"
}
],
"stack":"..."
}
New:
{
"errors":[
{
"type":"json",
"keyword":"minProperties",
"dataPath":"",
"message":"should NOT have fewer than 2 properties",
"data":{
"firstName":"John"
},
"schema":2
}
],
"stack":"..."
}
RAML validation responses examples
Number value is greater than the "maximum":
Old:
{
"errors":[
{
"type":"json",
"dataPath":"age",
"keyword":"maximum",
"schema":99,
"data":200,
"message":"Value 200 is greater than maximum 99"
}
],
"stack":"..."
}
New:
{
"errors":[
{
"type":"json",
"keyword":"maximum",
"dataPath":"/age",
"message":"should be <= 99",
"data":200,
"schema":99
}
],
"stack":"..."
}
Less properties than "minProperties":
Old:
{
"errors":[
{
"type":"json",
"keyword":"minProperties",
"schema":2,
"message":"Too few properties defined, minimum 2"
}
],
"stack":"..."
}
New:
{
"errors":[
{
"type":"json",
"keyword":"minProperties",
"dataPath":"",
"message":"should NOT have fewer than 2 properties",
"data":{
"firstName":"John"
},
"schema":2
}
],
"stack":"..."
}
Remove libxmljs from released dependencies
BREAKING:
Library libxmljs
is not installed any more when installing osprey-method-handler
.
This was the initially intended behaviour/output. So far libxmljs
was added as a package dependency by mistake because of an incorrect Travis configuration.
Projects that use XML validation but not specify libxmljs
as an explicit dependency will break. To make such a project work with new osprey-method-handler
versions, please make sure to install libxmljs
yourself.
v0.13.3
v0.13.2
IMPORTANT: This is an accidental breaking release. It's changes are undone in the next patch version (0.13.3) and reimplemented in the next minor version (0.14.0).
BREAKING: Make libxmljs
a truly optional dependency. Previously it was added to dependencies by mistake because of incorrect Travis config.
v0.13.0
Updated dependencies
RAML 1.0 support improved
- Allow other types than only objects as root type in RAML 1.0, thanks @cmd-johnson! (#25)
- Fixed TypeError: Cannot read property 'constructor' of undefined, merci @MaxenceDupressoir! (#26)
RAML 1.0 support
v0.11.0 version 0.11.0 with support for RAML 1.0 types
Update dependencies to latest releases
We updated a number of dependencies, which fix issues in Osprey.
AJV Error Data Path
Changed
- Use
errorDataPath
with latest AJV to getdataPath
to error property, not error object