Skip to content

Commit df7ca99

Browse files
author
Sascha Goldhofer
committed
docs: fix spacing
1 parent ce19f3e commit df7ca99

File tree

1 file changed

+41
-39
lines changed

1 file changed

+41
-39
lines changed

README.md

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<a href="#overview"><b>Overview</b></a> · <a href="#schemanode-methods"><b>Methods</b></a> · <a href="#draft-customization"><b>Customization</b></a> · <a href="#keyword-extensions"><b>Extensions</b></a> · <a href="#breaking-changes">Breaking Changes</a>
1515
</div>
1616

17+
---
18+
1719
**Quick start**
1820

1921
`npm install json-schema-library`
@@ -112,8 +114,8 @@ console.log(titleNode.evaluationPath); // #/properties/image/properties/title
112114
console.log(titleNode.schemaLocation); // #/properties/image/properties/title
113115
```
114116

115-
- `evaluationPath` refers to the path in schema and is extended by `$ref`, e.g. if image is defined on `$defs`: `#/properties/image/$ref/properties/title`
116-
- `schemaLocation` refers to the absolute path within the schema and will not change, e.g. `#/$defs/properties/title`
117+
- `evaluationPath` refers to the path in schema and is extended by `$ref`, e.g. if image is defined on `$defs`: `#/properties/image/$ref/properties/title`
118+
- `schemaLocation` refers to the absolute path within the schema and will not change, e.g. `#/$defs/properties/title`
117119

118120
</details>
119121

@@ -161,17 +163,17 @@ _json-schema-library_ fully supports all core features of draft versions draft-0
161163

162164
Draft support is defined by running a validator against the official [json-schema-test-suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite).
163165

164-
- Test results for _json-schema-library_ can be inspected in [github actions](https://github.com/sagold/json-schema-library/actions/workflows/ci.yaml)
165-
- A comparison to other validators is listed on [json-schema-benchmark](https://github.com/sagold/json-schema-benchmark)
166+
- Test results for _json-schema-library_ can be inspected in [github actions](https://github.com/sagold/json-schema-library/actions/workflows/ci.yaml)
167+
- A comparison to other validators is listed on [json-schema-benchmark](https://github.com/sagold/json-schema-benchmark)
166168

167169
Please note that these benchmarks refer to validation only. _json-schema-library_ offers tooling outside of validation and strives to be as spec-compliant as possible.
168170

169171
</details>
170172

171173
<details><summary>Overview format validation support</summary>
172174

173-
- **`❌ unsupported formats`** iri, iri-reference, idn-hostname
174-
- **`✅ supported formats`**: date, date-time, date, duration, ecmascript-regex, email, hostname, idn-email, ipv4, ipv6, json-pointer, regex, relative-json-pointer, time, unknown, uri-reference, uri-template, uri, uuid
175+
- **`❌ unsupported formats`** iri, iri-reference, idn-hostname
176+
- **`✅ supported formats`**: date, date-time, date, duration, ecmascript-regex, email, hostname, idn-email, ipv4, ipv6, json-pointer, regex, relative-json-pointer, time, unknown, uri-reference, uri-template, uri, uuid
175177

176178
</details>
177179

@@ -629,9 +631,9 @@ expect(node.schema).to.deep.equal({
629631

630632
All returned json-errors have a data property with the following properties
631633

632-
- `pointer` JSON Pointer to the location where the error occured. In case of omitted data, this is the last JSON Schema location that could be resolved
633-
- `schema` the JSON Schema of the last resolved location and the source of the error
634-
- `value` the data value at this location that could not be resolved
634+
- `pointer` JSON Pointer to the location where the error occured. In case of omitted data, this is the last JSON Schema location that could be resolved
635+
- `schema` the JSON Schema of the last resolved location and the source of the error
636+
- `value` the data value at this location that could not be resolved
635637

636638
```ts
637639
const { error } = schemaNode.getNode("/list/1");
@@ -919,10 +921,10 @@ _json-schema-library_ uses the concept of **drafts** to support different versio
919921

920922
Each **draft** describes how a schema should be parsed, validated, and interpreted. Drafts can also be extended or modified to change or enhance behavior, such as:
921923

922-
- Replacing or adding new keywords (`oneOf`, `if/then`, custom ones, etc.)
923-
- Defining or overriding format validators (`format: "email"`, etc.)
924-
- Customizing or localizing error messages
925-
- Tweaking how schema nodes behave during parsing or resolution
924+
- Replacing or adding new keywords (`oneOf`, `if/then`, custom ones, etc.)
925+
- Defining or overriding format validators (`format: "email"`, etc.)
926+
- Customizing or localizing error messages
927+
- Tweaking how schema nodes behave during parsing or resolution
926928

927929
Out of the box, the library exports all compliant JSON Schema drafts:
928930

@@ -1121,10 +1123,10 @@ console.assert(valid, errors.at(0)?.message);
11211123

11221124
**Keywords** hold the main logic for JSON Schema functionality. Each `Keyword` corresponds to a JSON Schema keyword like `properties`, `prefixItems`, `oneOf`, etc and offers implementations to `parse`, `validate`, `resolve` and `reduce`. Note that support for each implementation is optional, dependending on the feature requirements. The main properties of a `Keyword`:
11231125

1124-
- a `Keyword` is only processed if the specified `keyword` is available as property on the JSON Schema
1125-
- an optional `order` property may be added as order of keyword execution is sometimes important (`additionalItems` last, `$ref` evaluation first)
1126-
- the list of keywords is unique by property-value `keyword`
1127-
- for a given function `addX`, a function `X` must be present
1126+
- a `Keyword` is only processed if the specified `keyword` is available as property on the JSON Schema
1127+
- an optional `order` property may be added as order of keyword execution is sometimes important (`additionalItems` last, `$ref` evaluation first)
1128+
- the list of keywords is unique by property-value `keyword`
1129+
- for a given function `addX`, a function `X` must be present
11281130

11291131
```ts
11301132
type Keyword = {
@@ -1302,8 +1304,8 @@ The new implementation revolves around compiling schemas into a **SchemaNode** t
13021304

13031305
#### Key Changes:
13041306

1305-
- **Compile Schema**: The `compileSchema` function now replaces the previous Draft-Class approach.
1306-
- **SchemaNode Representation**: All schemas are now represented as `SchemaNode`, which holds the schema and provides an easier way to work with them.
1307+
- **Compile Schema**: The `compileSchema` function now replaces the previous Draft-Class approach.
1308+
- **SchemaNode Representation**: All schemas are now represented as `SchemaNode`, which holds the schema and provides an easier way to work with them.
13071309

13081310
#### Breaking Changes:
13091311

@@ -1319,14 +1321,14 @@ const node = compileSchema(schema);
13191321

13201322
**Changed Methods**:
13211323

1322-
- `draft.createSchemaOf(schema)``node.createSchema(schema)`
1323-
- `draft.each(data, callback)``const nodes = node.toDataNodes(data)`
1324-
- `draft.eachSchema(callback)``const nodes = node.toSchemaNodes()`
1325-
- `draft.getChildSchemaSelection(property)``node.getChildSelection(property)`
1326-
- `draft.getNode(options)``node.getNode(pointer, data, options)`
1327-
- `draft.getTemplate(inputData)``node.getData(inputData)`
1328-
- `draft.isValid(data)``node.validate(data).valid`
1329-
- `draft.step(property, data)``node.getNodeChild(property, data)`
1324+
- `draft.createSchemaOf(schema)``node.createSchema(schema)`
1325+
- `draft.each(data, callback)``const nodes = node.toDataNodes(data)`
1326+
- `draft.eachSchema(callback)``const nodes = node.toSchemaNodes()`
1327+
- `draft.getChildSchemaSelection(property)``node.getChildSelection(property)`
1328+
- `draft.getNode(options)``node.getNode(pointer, data, options)`
1329+
- `draft.getTemplate(inputData)``node.getData(inputData)`
1330+
- `draft.isValid(data)``node.validate(data).valid`
1331+
- `draft.step(property, data)``node.getNodeChild(property, data)`
13301332

13311333
**Renamed Properties**: `templateDefaultOptions``getDataDefaultOptions`
13321334

@@ -1352,28 +1354,28 @@ compileSchema(schema, {
13521354

13531355
**breaking changes**:
13541356

1355-
- _getSchema_ signature changed in favour of an options object. Instead of `draft.getNode(pointer, data)` arguments have to be passed as an object `draft.getNode({ pointer, data })`. This removes setting unwanted optional arguments and keeps the api more stable in the future (e.g. `withSchemaWarning` option)
1356-
- _JsonError_ now must expose `pointer`, `schema` and `value` consistently on data property
1357+
- _getSchema_ signature changed in favour of an options object. Instead of `draft.getNode(pointer, data)` arguments have to be passed as an object `draft.getNode({ pointer, data })`. This removes setting unwanted optional arguments and keeps the api more stable in the future (e.g. `withSchemaWarning` option)
1358+
- _JsonError_ now must expose `pointer`, `schema` and `value` consistently on data property
13571359

13581360
**updates**
13591361

1360-
- _getSchema_ consistently returns errors and can return errors for empty schema using `withSchemaWarning` option
1362+
- _getSchema_ consistently returns errors and can return errors for empty schema using `withSchemaWarning` option
13611363

13621364
### v8.0.0
13631365

13641366
With version `v8.0.0`, _getData_ was improved to better support optional properties and utilize existing core logic, making it more reliable. Breaking changes:
13651367

1366-
- Renamed `JSONError` to `JsonError` and `JSONSchema` to `JsonSchema`
1367-
- `getData` only adds required properties. Behaviour can be changed by [getData default options](#getData-default-options)
1368-
- Internal schema property `oneOfSchema` has been replaced by `schema.getOneOfOrigin()`
1369-
- Changed `unique-items-error` to point to error for duplicated item and changed data-properties
1370-
- Removed `SchemaService` as it was no longer used nor tested
1368+
- Renamed `JSONError` to `JsonError` and `JSONSchema` to `JsonSchema`
1369+
- `getData` only adds required properties. Behaviour can be changed by [getData default options](#getData-default-options)
1370+
- Internal schema property `oneOfSchema` has been replaced by `schema.getOneOfOrigin()`
1371+
- Changed `unique-items-error` to point to error for duplicated item and changed data-properties
1372+
- Removed `SchemaService` as it was no longer used nor tested
13711373

13721374
<details><summary>Exposed new helper functions</summary>
13731375

1374-
- `mergeSchema` - Merges to two json schema
1375-
- `reduceNode` - Reduce schema by merging dynamic constructs into a static json schema omitting those properties
1376-
- `isDynamicSchema` - Returns true if the passed schema contains dynamic properties (_if_, _dependencies_, _allOf_, etc)
1377-
- `resolveDynamicSchema` - Resolves all dynamic schema definitions for the given input data and returns the resulting JSON Schema without any dynamic schema definitions.
1376+
- `mergeSchema` - Merges to two json schema
1377+
- `reduceNode` - Reduce schema by merging dynamic constructs into a static json schema omitting those properties
1378+
- `isDynamicSchema` - Returns true if the passed schema contains dynamic properties (_if_, _dependencies_, _allOf_, etc)
1379+
- `resolveDynamicSchema` - Resolves all dynamic schema definitions for the given input data and returns the resulting JSON Schema without any dynamic schema definitions.
13781380

13791381
</details>

0 commit comments

Comments
 (0)