Commit Graph

315 Commits (ecd1ed455d02f8e5406815889ced04788e89f2a2)

Author SHA1 Message Date
Evgeny Poberezkin 8413890875 fix: schema "dependencies" with property containing single quotes, closes #413 2017-02-12 00:21:53 +00:00
Evgeny Poberezkin aa8de572df feat: custom keywords with predefined validation result, #393 2017-01-20 23:08:52 +00:00
Evgeny Poberezkin 33845cc397 feat: support custom keywords that modify data, #392 2017-01-20 22:03:36 +00:00
Evgeny Poberezkin 2468bd5014 refactor: custom keyword code generation, #392 2017-01-20 21:33:34 +00:00
Evgeny Poberezkin 82002ec5e8 test: failing test for custom keyword mutating data, #141, #392 2017-01-20 20:26:14 +00:00
Richard Taylor b1b0c553d8 Improve implementation of allowing hyphens in keywords
This:
- Updates the README with the new rules (and recommendations)
- Updates `keyword.js` to implement the agreed change to the naming rules:
- - Now same as before but also allow hyphens as second and subsequent characters
- Update tests to test the new keyword naming rules
- Update `definitions.def` to use it.util.getProperty() to dynamically choose dot
  or bracket notation as appropriate rather than hardcode bracket notation.

Test Plan:
- Run `npm test` and ensure all tests run and pass
2017-01-05 18:28:28 +00:00
Richard Taylor 66db560ca5 Allow custom keywords that are not valid JS identifiers
Custom keywords were required to be valid JS identifiers due to the
way they were being used in the generated code.  This prevented the use
of keywords with the `x-` prefix that is required by [swagger](http://swagger.io].

This change fixes that by updating the only place that was using them
directly as an identifier to use //brackets// notation rather than
//dot// notation.  This brings the definition of `$schemaPath` in
`definitions.def` in line with the way the rule definition is accessed
from `RULES.custom` at the top of `custom.jst`.

The validation of the keyword name has been changed to allow any name
in this change, but this should be updated to either just remove the
test or update it to a new rule before this change is included in
the project.

Finally, this also updates a number of the tests in `custom.spec.js` to
use non-valid identifiers for the names of some of the custom keywords
being tested (primarily by adding `x-` to the front of the name).

Test Plan:
- Run `npm test` and ensure all tests run and pass
2017-01-05 10:48:12 +00:00
Evgeny Poberezkin c4335abf53 fix: allOf with empty schemas failing compilation, fixes #381 2016-12-24 23:42:36 +00:00
Evgeny Poberezkin 23f2572d1c fix: formats json-pointer and relative-json-pointer now support empty fragments 2016-12-23 17:34:25 +00:00
Evgeny Poberezkin 7bfc868816 test: getKeyword, removeKeyword methods 2016-12-11 12:12:27 +00:00
Evgeny Poberezkin 3e666bc250 test: fix typo in file name 2016-12-03 19:26:30 +00:00
Evgeny Poberezkin 00bf5c77ee fix: compare Date and RegExp objects, closes #342 2016-11-14 18:27:40 +00:00
Evgeny Poberezkin eefa467446 test: not whitelisted unknown format in $data fails validation, #310 2016-10-16 16:11:44 +01:00
Evgeny Poberezkin c55ef280dc feat: optionally fail validation of unknown format passed via $data, #310 2016-10-16 16:11:25 +01:00
Evgeny Poberezkin 01ff755d4b test: whitelisted unknown formats should be valid (remove warnings), #310 2016-10-16 12:32:44 +01:00
Evgeny Poberezkin 9bd850d115 feat: optionally throw exception during schema compilation if unknown format is used, #310 2016-10-16 11:57:49 +01:00
Evgeny Poberezkin 0944949b08 test: option unknownFormats, #310 2016-10-16 11:32:12 +01:00
Evgeny Poberezkin a3ab001d5b fix: do NOT log warning if extendRef is explicitely set to true, fix schema path in messages; closes #303 2016-10-05 18:11:31 +01:00
Evgeny Poberezkin da24fd33e1 test: refactor schema tests, use nyc 2016-10-04 21:16:18 +01:00
Evgeny Poberezkin 72a3bd0c2a fix: allow segments of hostnames to start with digit, closes #312 2016-10-02 18:21:17 +01:00
Evgeny Poberezkin 7c95ec9fa8 fix: escaped characters in $refs, closes #311 2016-09-28 14:28:52 +01:00
Evgeny Poberezkin cdd30a9776 fix: allow null as schema value in keywords that support $data reference (constant) 2016-09-22 15:40:38 +01:00
Evgeny Poberezkin 1c28d6dc34 test: sourceCode option, #293 2016-09-06 21:49:01 +01:00
Evgeny Poberezkin 3806b9d8a3 fix: correctly resolve $data refs with absolute JSON pointers, #289 2016-08-29 22:26:33 +01:00
Don Rouse c6e42e7e5c Add tests for $data ref with absolute JSON pointers 2016-08-26 17:36:37 -07:00
Evgeny Poberezkin 7e7219212d feat: allow refs with protocol-relative URIs, closes #277 2016-08-15 21:53:09 +01:00
Evgeny Poberezkin 2d9241a658 feat: allow refs to fragments in "getSchema" and "validate" methods, closes #47 2016-08-15 21:22:07 +01:00
Evgeny Poberezkin 86114c56dd style: no empty parens in constructor calls 2016-08-07 11:31:55 +01:00
Evgeny Poberezkin c103dc04b9 feat: support validating [meta-]schemas against themselves, closes #259 2016-08-07 00:37:30 +01:00
Evgeny Poberezkin b9a2e5907d test: increase timeout 2016-08-06 21:36:07 +01:00
Evgeny Poberezkin 3185847572 feat: log warning if other keywords are used with "$ref", #260 2016-08-06 21:10:57 +01:00
Evgeny Poberezkin 39b4a8f637 feat: option "extendRefs" to fail compilation or to ignore other keywords when "$ref" is used, closes #260 2016-08-06 13:05:39 +01:00
Evgeny Poberezkin 3011bff559 test: option "extendRefs", #260 2016-08-06 11:44:18 +01:00
Evgeny Poberezkin 321a6d1a83 fix: date-time validation, closes #261 2016-08-05 11:57:58 +01:00
Victor Emanouilov 6df7b2040b fix: date-time string validation to fail validating for date-only strings instead of throwing a TypeError 2016-08-04 13:49:53 +03:00
Evgeny Poberezkin 62eaf92c4c
test: more test cases for coersion of array to scalar, #158 2016-07-28 22:23:18 +01:00
Evgeny Poberezkin b853218249
style: eslint tests, closes #250 2016-07-28 00:50:30 +01:00
Evgeny Poberezkin 0630539aa3
test: coerceTypes: "array" coercion should fail if array length != 1, #158 2016-07-27 22:17:06 +01:00
will Farrell a21cf02f43 update `==`, `object <-> array` 2016-07-26 14:43:20 -06:00
will Farrell ec09c3c735 allow reversal and add more tests 2016-07-24 19:03:27 -06:00
will Farrell 9e18e68ce7 Add in ability to coerce to an array 2016-07-22 18:07:10 -06:00
Evgeny Poberezkin d64b84f5ff
Merge branch 'master' into 4.2 2016-07-22 15:00:44 +01:00
Evgeny Poberezkin ac5c746f0a
Revert "Revert "feat: meta schema for custom keywords schemas, closes #230""
This reverts commit 09879d21ad.
2016-07-22 14:49:43 +01:00
Evgeny Poberezkin 5a80c7cff6
feat: support meta-schema validation in custom keywords with $data support, #146 2016-07-22 14:25:41 +01:00
Evgeny Poberezkin f06008a84f
fix: error when mutually recursive fragment refs reference a common schema, closes #240 2016-07-22 00:37:35 +01:00
Evgeny Poberezkin c2609392a2
test: passing/failing tests for #240 - mutually recursive fragment refs reference a common schema 2016-07-21 23:08:42 +01:00
Evgeny Poberezkin 7f5fe70cdb
feat: $data support in custom keywords, #146 2016-07-19 22:50:10 +01:00
Evgeny Poberezkin 09879d21ad
Revert "feat: meta schema for custom keywords schemas, closes #230"
This reverts commit 1a6e4b576c.
2016-07-18 18:51:57 +01:00
Evgeny Poberezkin 1a6e4b576c
feat: meta schema for custom keywords schemas, closes #230 2016-07-17 11:20:47 +01:00
Evgeny Poberezkin 2bcb74fc8c
fix: support mutual recursive refs when both refs are schema fragments, closes #210 2016-07-10 18:36:09 +01:00