Skip to content

Commit

Permalink
fix(ns-json-schema-draft-7): add missing method overrides (#4668)
Browse files Browse the repository at this point in the history
Refs #1819
  • Loading branch information
glowcloud authored Jan 21, 2025
1 parent 6b208ed commit 15d2866
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/apidom-ns-json-schema-draft-7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const plugin = ({ predicates, namespace }) => ({
},
});

MediaElement.refract(objectElement, { plugins: [plugin] }); // => LinkDescriptionElement({ anchor = 'nodes/{thisNodeId}', anchorPointer = '#/relative/json/pointer/x' })
LinkDescriptionElement.refract(objectElement, { plugins: [plugin] }); // => LinkDescriptionElement({ anchor = 'nodes/{thisNodeId}', anchorPointer = '#/relative/json/pointer/x' })
```

You can define as many plugins as needed to enhance the resulting namespaced ApiDOM structure.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { StringElement, BooleanElement, Attributes, Meta } from '@swagger-api/apidom-core';
import {
StringElement,
BooleanElement,
ArrayElement,
Attributes,
Meta,
} from '@swagger-api/apidom-core';
import { UnsupportedOperationError } from '@swagger-api/apidom-error';
import {
JSONSchemaElement,
Expand Down Expand Up @@ -36,6 +42,38 @@ class JSONSchema extends JSONSchemaElement {
* URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01
*/

/**
* Validation keywords for arrays
*/

get containsProp(): this | BooleanElement | JSONReferenceElement | undefined {
return this.get('contains');
}

set containsProp(contains: this | BooleanElement | JSONReferenceElement | undefined) {
this.set('contains', contains);
}

get items(): this | BooleanElement | JSONReferenceElement | ArrayElement | undefined {
return this.get('items');
}

set items(items: this | BooleanElement | JSONReferenceElement | ArrayElement | undefined) {
this.set('items', items);
}

/**
* Validation keywords for objects
*/

get propertyNames(): this | BooleanElement | JSONReferenceElement | undefined {
return this.get('propertyNames');
}

set propertyNames(propertyNames: this | BooleanElement | JSONReferenceElement | undefined) {
this.set('propertyNames', propertyNames);
}

/**
* Keywords for Applying Subschemas Conditionally
*
Expand Down Expand Up @@ -66,6 +104,20 @@ class JSONSchema extends JSONSchemaElement {
this.set('else', elseValue);
}

/**
* Keywords for Applying Subschemas With Boolean Logic
*
* URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6.7
*/

get not(): this | BooleanElement | JSONReferenceElement | undefined {
return this.get('not');
}

set not(not: this | BooleanElement | JSONReferenceElement | undefined) {
this.set('not', not);
}

/**
* String-Encoding Non-JSON Data
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ class LinkDescription extends LinkDescriptionElement {
* URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.5
*/

get targetSchema(): JSONSchema | BooleanElement | JSONReferenceElement | undefined {
return this.get('targetSchema');
}

set targetSchema(targetSchema: JSONSchema | BooleanElement | JSONReferenceElement | undefined) {
this.set('targetSchema', targetSchema);
}

get mediaType(): StringElement | undefined {
throw new UnsupportedOperationError(
'mediaType keyword from Hyper-Schema vocabulary has been renamed to targetMediaType.',
Expand Down Expand Up @@ -119,6 +127,15 @@ class LinkDescription extends LinkDescriptionElement {
*
* URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.6
*/

get hrefSchema(): JSONSchema | BooleanElement | JSONReferenceElement | undefined {
return this.get('hrefSchema');
}

set hrefSchema(hrefSchema: JSONSchema | BooleanElement | JSONReferenceElement | undefined) {
this.set('hrefSchema', hrefSchema);
}

get headerSchema(): JSONSchema | BooleanElement | JSONReferenceElement | undefined {
return this.get('headerSchema');
}
Expand All @@ -132,6 +149,17 @@ class LinkDescription extends LinkDescriptionElement {
*
* URI: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-01#section-6.6.4
*/

get submissionSchema(): JSONSchema | BooleanElement | JSONReferenceElement | undefined {
return this.get('submissionSchema');
}

set submissionSchema(
submissionSchema: JSONSchema | BooleanElement | JSONReferenceElement | undefined,
) {
this.set('submissionSchema', submissionSchema);
}

get submissionEncType(): StringElement | undefined {
throw new UnsupportedOperationError(
'submissionEncType keyword from Hyper-Schema vocabulary has been renamed to submissionMediaType.',
Expand Down

0 comments on commit 15d2866

Please sign in to comment.