Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.

Releases: mulesoft-labs/osprey-method-handler

Rewrote to work with webapi-parser

Choose a tag to compare

@postatum postatum released this 28 Jul 08:07

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 of var;

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

Choose a tag to compare

@postatum postatum released this 12 May 08:10

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

Choose a tag to compare

@postatum postatum released this 12 May 07:55

Undo changes in version 0.13.2 to avoid releasing breaking changes in a patch version.

v0.13.2

Choose a tag to compare

@postatum postatum released this 12 May 07:47

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

Choose a tag to compare

@postatum postatum released this 07 May 07:13
  • Updated dependencies
  • Dropped Node 8 support

Updated dependencies

Choose a tag to compare

@jstoiko jstoiko released this 02 Apr 21:29

Updated dependencies.

Fixes

  • Issue validating against !included JSON schemas in types #29

RAML 1.0 support improved

Choose a tag to compare

@jstoiko jstoiko released this 08 Apr 04:17
  • 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

Choose a tag to compare

@jstoiko jstoiko released this 01 Mar 01:10
v0.11.0

version 0.11.0 with support for RAML 1.0 types

Update dependencies to latest releases

Choose a tag to compare

@dmartinezg dmartinezg released this 02 Jun 15:15

We updated a number of dependencies, which fix issues in Osprey.

AJV Error Data Path

Choose a tag to compare

@blakeembrey blakeembrey released this 10 Feb 04:25

Changed

  • Use errorDataPath with latest AJV to get dataPath to error property, not error object