Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ns-openapi-2): add support for Items Object #3248

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/apidom-ns-openapi-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Only fully implemented specification objects should be checked here.
- [ ] [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#user-content-operation-object)
- [x] [External Documentation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#user-content-external-documentation-object)
- [ ] [Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#user-content-parameter-object)
- [ ] [Items Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#user-content-items-object)
- [x] [Items Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#user-content-items-object)
- [ ] [Responses Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#user-content-responses-object)
- [ ] [Response Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#user-content-response-object)
- [ ] [Headers Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#user-content-headers-object)
Expand Down
1 change: 1 addition & 0 deletions packages/apidom-ns-openapi-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"dependencies": {
"@babel/runtime-corejs3": "^7.20.7",
"@swagger-api/apidom-core": "^0.77.0",
"@swagger-api/apidom-error": "^0.77.0",
"@swagger-api/apidom-ns-json-schema-draft-4": "^0.77.0",
"@types/ramda": "~0.29.3",
"ramda": "~0.29.0",
Expand Down
276 changes: 276 additions & 0 deletions packages/apidom-ns-openapi-2/src/elements/Items.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
import {
StringElement,
BooleanElement,
Attributes,
Meta,
NumberElement,
ArrayElement,
ObjectElement,
} from '@swagger-api/apidom-core';
import { UnsupportedOperationError } from '@swagger-api/apidom-error';
import {
JSONReferenceElement,
JSONSchemaElement,
MediaElement,
} from '@swagger-api/apidom-ns-json-schema-draft-4';

/* eslint-disable class-methods-use-this */
class Items extends JSONSchemaElement {
constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes) {
super(content, meta, attributes);
this.element = 'items';
this.classes.push('json-schema-draft-4');
}

/**
* Core vocabulary
*
* URI: https://tools.ietf.org/html/draft-wright-json-schema-00
*/
get idProp(): StringElement | undefined {
throw new UnsupportedOperationError('idProp getter in Items class is not not supported.');
}

set idProp(idProps: StringElement | undefined) {
throw new UnsupportedOperationError('idProp setter in Items class is not not supported.');
}

get $schema(): StringElement | undefined {
throw new UnsupportedOperationError('$schema getter in Items class is not not supported.');
}

set $schema($schema: StringElement | undefined) {
throw new UnsupportedOperationError('$schema setter in Items class is not not supported.');
}

/**
* Validation keywords for arrays
*/

get additionalItems(): this | JSONReferenceElement | BooleanElement | undefined {
throw new UnsupportedOperationError(
'additionalItems getter in Items class is not not supported.',
);
}

set additionalItems(additionalItems: this | JSONReferenceElement | BooleanElement | undefined) {
throw new UnsupportedOperationError(
'additionalItems setter in Items class is not not supported.',
);
}

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

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

/**
* Validation keywords for objects
*/

get maxProperties(): NumberElement | undefined {
throw new UnsupportedOperationError(
'maxProperties getter in Items class is not not supported.',
);
}

set maxProperties(maxProperties: NumberElement | undefined) {
throw new UnsupportedOperationError(
'maxProperties setter in Items class is not not supported.',
);
}

get minProperties(): NumberElement | undefined {
throw new UnsupportedOperationError(
'minProperties getter in Items class is not not supported.',
);
}

set minProperties(minProperties: NumberElement | undefined) {
throw new UnsupportedOperationError(
'minProperties setter in Items class is not not supported.',
);
}

get required(): ArrayElement | undefined {
throw new UnsupportedOperationError('required getter in Items class is not not supported.');
}

set required(required: ArrayElement | undefined) {
throw new UnsupportedOperationError('required setter in Items class is not not supported.');
}

get properties(): ObjectElement | undefined {
throw new UnsupportedOperationError('properties getter in Items class is not not supported.');
}

set properties(properties: ObjectElement | undefined) {
throw new UnsupportedOperationError('properties setter in Items class is not not supported.');
}

get additionalProperties(): this | JSONReferenceElement | BooleanElement | undefined {
throw new UnsupportedOperationError(
'additionalProperties getter in Items class is not not supported.',
);
}

set additionalProperties(
additionalProperties: this | JSONReferenceElement | BooleanElement | undefined,
) {
throw new UnsupportedOperationError(
'additionalProperties setter in Items class is not not supported.',
);
}

get patternProperties(): ObjectElement | undefined {
throw new UnsupportedOperationError(
'patternProperties getter in Items class is not not supported.',
);
}

set patternProperties(patternProperties: ObjectElement | undefined) {
throw new UnsupportedOperationError(
'patternProperties setter in Items class is not not supported.',
);
}

get dependencies(): ObjectElement | undefined {
throw new UnsupportedOperationError('dependencies getter in Items class is not not supported.');
}

set dependencies(dependencies: ObjectElement | undefined) {
throw new UnsupportedOperationError('dependencies setter in Items class is not not supported.');
}

/**
* Validation keywords for any instance type
*/

get type(): StringElement | undefined {
return this.get('type');
}

set type(type: StringElement | undefined) {
this.set('type', type);
}

get allOf(): ArrayElement | undefined {
throw new UnsupportedOperationError('allOf getter in Items class is not not supported.');
}

set allOf(allOf: ArrayElement | undefined) {
throw new UnsupportedOperationError('allOf setter in Items class is not not supported.');
}

get anyOf(): ArrayElement | undefined {
throw new UnsupportedOperationError('anyOf getter in Items class is not not supported.');
}

set anyOf(anyOf: ArrayElement | undefined) {
throw new UnsupportedOperationError('anyOf setter in Items class is not not supported.');
}

get oneOf(): ArrayElement | undefined {
throw new UnsupportedOperationError('oneOf getter in Items class is not not supported.');
}

set oneOf(oneOf: ArrayElement | undefined) {
throw new UnsupportedOperationError('oneOf setter in Items class is not not supported.');
}

get not(): this | JSONReferenceElement | undefined {
throw new UnsupportedOperationError('not getter in Items class is not not supported.');
}

set not(not: this | JSONReferenceElement | undefined) {
throw new UnsupportedOperationError('not setter in Items class is not not supported.');
}

get definitions(): ObjectElement | undefined {
throw new UnsupportedOperationError('definitions getter in Items class is not not supported.');
}

set definitions(definitions: ObjectElement | undefined) {
throw new UnsupportedOperationError('definitions setter in Items class is not not supported.');
}

/**
* Metadata keywords
*
* URI: https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-6
*/

get title(): StringElement | undefined {
throw new UnsupportedOperationError('title getter in Items class is not not supported.');
}

set title(title: StringElement | undefined) {
throw new UnsupportedOperationError('title setter in Items class is not not supported.');
}

get description(): StringElement | undefined {
throw new UnsupportedOperationError('description getter in Items class is not not supported.');
}

set description(description: StringElement | undefined) {
throw new UnsupportedOperationError('description setter in Items class is not not supported.');
}

/**
* Semantic validation with "format"
*
* URI: https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-7
*/

get format(): StringElement | undefined {
return this.get('format');
}

set format(format: StringElement | undefined) {
this.set('format', format);
}

/**
* JSON Hyper-Schema
*
* URI: https://datatracker.ietf.org/doc/html/draft-wright-json-schema-hyperschema-00
*/

get base(): StringElement | undefined {
throw new UnsupportedOperationError('base getter in Items class is not not supported.');
}

set base(base: StringElement | undefined) {
throw new UnsupportedOperationError('base setter in Items class is not not supported.');
}

get links(): ArrayElement | undefined {
throw new UnsupportedOperationError('links getter in Items class is not not supported.');
}

set links(links: ArrayElement | undefined) {
throw new UnsupportedOperationError('links setter in Items class is not not supported.');
}

get media(): MediaElement | undefined {
throw new UnsupportedOperationError('media getter in Items class is not not supported.');
}

set media(media: MediaElement | undefined) {
throw new UnsupportedOperationError('media setter in Items class is not not supported.');
}

get readOnly(): BooleanElement | undefined {
throw new UnsupportedOperationError('readOnly getter in Items class is not not supported.');
}

set readOnly(readOnly: BooleanElement | undefined) {
throw new UnsupportedOperationError('readOnly setter in Items class is not not supported.');
}
}
/* eslint-enable class-methods-use-this */

export default Items;
2 changes: 2 additions & 0 deletions packages/apidom-ns-openapi-2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export {
isLicenseElement,
isContactElement,
isExternalDocumentationElement,
isItemsElement,
isExampleElement,
isTagElement,
isXmlElement,
Expand All @@ -41,6 +42,7 @@ export {
LicenseElement,
ContactElement,
ExternalDocumentationElement,
ItemsElement,
ExampleElement,
TagElement,
XmlElement,
Expand Down
2 changes: 2 additions & 0 deletions packages/apidom-ns-openapi-2/src/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import InfoElement from './elements/Info';
import LicenseElement from './elements/License';
import ContactElement from './elements/Contact';
import ExternalDocumentation from './elements/ExternalDocumentation';
import ItemsElement from './elements/Items';
import ExampleElement from './elements/Example';
import TagElement from './elements/Tag';
import XmlElement from './elements/Xml';
Expand All @@ -20,6 +21,7 @@ const openApi2 = {
base.register('license', LicenseElement);
base.register('contact', ContactElement);
base.register('externalDocumentation', ExternalDocumentation);
base.register('items', ItemsElement);
base.register('example', ExampleElement);
base.register('tag', TagElement);
base.register('xml', XmlElement);
Expand Down
Loading