Skip to content

Commit

Permalink
Add option to skip context validation: skipContextValidation
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Apr 16, 2021
1 parent e947d07 commit d7261ca
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Optionally, the following parameters can be set in the `JsonLdParser` constructo
* `rdfDirection`: The [mode](https://w3c.github.io/json-ld-api/#dom-jsonldoptions-rdfdirection) under which `@direction` should be handled. If undefined, `@direction` is ignored. Alternatively, it can be set to either `'i18n-datatype'` or `'compound-literal'` _(Default: `undefined`)_
* `normalizeLanguageTags`: Whether or not language tags should be normalized to lowercase. _(Default: `false` for JSON-LD 1.1 (and higher), `true` for JSON-LD 1.0)_
* `streamingProfileAllowOutOfOrderPlainType`: When the streaming profile flag is enabled, `@type` entries MUST come before other properties since they may defined a type-scoped context. However, when this flag is enabled, `@type` entries that do NOT define a type-scoped context may appear anywhere just like a regular property.. _(Default: `false`)_
* `skipContextValidation`: If JSON-LD context validation should be skipped. This is useful when parsing large contexts that are known to be valid. _(Default: `false`)_

```javascript
new JsonLdParser({
Expand Down
6 changes: 6 additions & 0 deletions lib/JsonLdParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,4 +619,10 @@ export interface IJsonLdParserOptions {
* define a type-scoped context may appear anywhere just like a regular property.
*/
streamingProfileAllowOutOfOrderPlainType?: boolean;
/**
* If JSON-LD context validation should be skipped.
*
* This is useful when parsing large contexts that are known to be valid.
*/
skipContextValidation?: boolean;
}
2 changes: 1 addition & 1 deletion lib/ParsingContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class ParsingContext {

constructor(options: IParsingContextOptions) {
// Initialize settings
this.contextParser = new ContextParser({ documentLoader: options.documentLoader });
this.contextParser = new ContextParser({ documentLoader: options.documentLoader, skipValidation: options.skipContextValidation });
this.streamingProfile = !!options.streamingProfile;
this.baseIRI = options.baseIRI;
this.produceGeneralizedRdf = !!options.produceGeneralizedRdf;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@types/rdf-js": "*",
"http-link-header": "^1.0.2",
"canonicalize": "^1.0.1",
"jsonld-context-parser": "^2.1.1",
"jsonld-context-parser": "^2.1.2",
"jsonparse": "^1.3.1",
"rdf-data-factory": "^1.0.4"
},
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2621,10 +2621,10 @@ jsonld-context-parser@^2.0.0:
isomorphic-fetch "^2.2.1"
relative-to-absolute-iri "^1.0.5"

jsonld-context-parser@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/jsonld-context-parser/-/jsonld-context-parser-2.1.1.tgz#0de2b459465b199ef6014a94d7af9b2485360374"
integrity sha512-7yKhnwFaiCnDPUZYQuAWyT0zZBfOKZDyjtqFVNbXrYRkboU+m55UsastsfXbo7qNroTGdFiEyxHEHDEfBC0P4Q==
jsonld-context-parser@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/jsonld-context-parser/-/jsonld-context-parser-2.1.2.tgz#17e9e749488cc91e91ddbb6d2edc901bdf55023f"
integrity sha512-zAhus+dz4IrXiYAiYf6M1PSdYkILVWPg4bqqGfim+rGrmVc3d0drFAriLOU2RMwQFKljM+41lJTau47sxt6YWA==
dependencies:
"@types/http-link-header" "^1.0.1"
"@types/node" "^13.1.0"
Expand Down

0 comments on commit d7261ca

Please sign in to comment.