From 10b5f724d9e65fb76d8b7a43c82436a22340a6b6 Mon Sep 17 00:00:00 2001 From: Matatjahu Date: Thu, 28 Apr 2022 12:13:23 +0200 Subject: [PATCH] refactor: add all missed interfaces --- src/models/channel-parameter.ts | 3 +++ src/models/channel-parameters.ts | 4 ++++ src/models/channel.ts | 3 +++ src/models/channels.ts | 4 ++++ src/models/collection.ts | 4 ++-- src/models/components.ts | 32 ++++++++++++++++++++++++++++++++ src/models/contact.ts | 1 - src/models/correlation-id.ts | 3 +++ src/models/info.ts | 1 - src/models/license.ts | 1 - src/models/message-example.ts | 3 +++ src/models/message-trait.ts | 3 +++ src/models/message-traits.ts | 4 ++++ src/models/message.ts | 4 ++++ src/models/messages.ts | 4 ++++ src/models/operation-trait.ts | 3 +++ src/models/operation-traits.ts | 4 ++++ src/models/operation.ts | 4 ++++ src/models/operations.ts | 4 ++++ src/models/schema.ts | 3 +++ src/models/schemas.ts | 4 ++++ src/models/server-variable.ts | 18 +++++++++--------- src/models/server-variables.ts | 4 ++-- src/models/server.ts | 2 +- src/models/servers.ts | 4 ++-- src/models/utils.ts | 10 ---------- 26 files changed, 105 insertions(+), 29 deletions(-) create mode 100644 src/models/channel-parameter.ts create mode 100644 src/models/channel-parameters.ts create mode 100644 src/models/channel.ts create mode 100644 src/models/channels.ts create mode 100644 src/models/components.ts create mode 100644 src/models/correlation-id.ts create mode 100644 src/models/message-example.ts create mode 100644 src/models/message-trait.ts create mode 100644 src/models/message-traits.ts create mode 100644 src/models/message.ts create mode 100644 src/models/messages.ts create mode 100644 src/models/operation-trait.ts create mode 100644 src/models/operation-traits.ts create mode 100644 src/models/operation.ts create mode 100644 src/models/operations.ts create mode 100644 src/models/schema.ts create mode 100644 src/models/schemas.ts diff --git a/src/models/channel-parameter.ts b/src/models/channel-parameter.ts new file mode 100644 index 000000000..bc60be07b --- /dev/null +++ b/src/models/channel-parameter.ts @@ -0,0 +1,3 @@ +import type { BaseModel } from "./base"; + +export interface ChannelParameterInterface extends BaseModel {} diff --git a/src/models/channel-parameters.ts b/src/models/channel-parameters.ts new file mode 100644 index 000000000..07ef58853 --- /dev/null +++ b/src/models/channel-parameters.ts @@ -0,0 +1,4 @@ +import type { Collection } from "./collection"; +import type { ChannelParameterInterface } from "./channel-parameter"; + +export interface ChannelParametersInterface extends Collection {} \ No newline at end of file diff --git a/src/models/channel.ts b/src/models/channel.ts new file mode 100644 index 000000000..75dae611b --- /dev/null +++ b/src/models/channel.ts @@ -0,0 +1,3 @@ +import type { BaseModel } from "./base"; + +export interface ChannelInterface extends BaseModel {} diff --git a/src/models/channels.ts b/src/models/channels.ts new file mode 100644 index 000000000..7383d16e0 --- /dev/null +++ b/src/models/channels.ts @@ -0,0 +1,4 @@ +import type { Collection } from "./collection"; +import type { ChannelInterface } from "./channel"; + +export interface ChannelsInterface extends Collection {} \ No newline at end of file diff --git a/src/models/collection.ts b/src/models/collection.ts index 9e8c89604..05c83c6ab 100644 --- a/src/models/collection.ts +++ b/src/models/collection.ts @@ -1,6 +1,6 @@ import type { BaseModel } from "./base"; -export abstract class Collection extends Array { +export abstract class Collection> extends Array { constructor( protected readonly collections: T[] ) { @@ -17,4 +17,4 @@ export abstract class Collection extends Array { isEmpty(): boolean { return this.collections.length === 0; } -} \ No newline at end of file +} diff --git a/src/models/components.ts b/src/models/components.ts new file mode 100644 index 000000000..9bca87a5a --- /dev/null +++ b/src/models/components.ts @@ -0,0 +1,32 @@ +import type { BaseModel } from './base'; +import type { Collection } from './collection'; +import type { ServersInterface } from './servers'; +import type { ChannelsInterface } from './channels'; +import type { OperationsInterface } from './operations'; +import type { OperationsTraitsInterface } from './operation-traits'; +import type { MessagesInterface } from './messages'; +import type { MessagesTraitsInterface } from './message-traits'; +import type { SchemasInterface } from './schemas'; +import type { ChannelParametersInterface } from './channel-parameters'; +import type { ServerVariablesInterface } from './server-variables'; +import type { CorrelationIdInterface } from './correlation-id'; +import type { BindingsInterface } from './bindings'; +import type { ExtensionsMixinInterface } from './mixins'; + +export interface Components extends BaseModel, ExtensionsMixinInterface { + servers(): ServersInterface; + channels(): ChannelsInterface; + operations(): OperationsInterface; + messages(): MessagesInterface; + schemas(): SchemasInterface; + channelParameters(): ChannelParametersInterface; + serverVariables(): ServerVariablesInterface; + operationTraits(): OperationsTraitsInterface; + messageTraits(): MessagesTraitsInterface; + correlationIds(): Collection; + securitySchemes(): any; // TODO: Fix type after merging Souvik PR + serverBindings(): Collection; + channelBindings(): Collection; + operationBindings(): Collection; + messageBindings(): Collection; +} diff --git a/src/models/contact.ts b/src/models/contact.ts index 709299095..f21dce2f7 100644 --- a/src/models/contact.ts +++ b/src/models/contact.ts @@ -1,5 +1,4 @@ import type { BaseModel } from "./base"; - import type { ExtensionsMixinInterface } from "./mixins"; export interface ContactInterface extends BaseModel, ExtensionsMixinInterface { diff --git a/src/models/correlation-id.ts b/src/models/correlation-id.ts new file mode 100644 index 000000000..347908f40 --- /dev/null +++ b/src/models/correlation-id.ts @@ -0,0 +1,3 @@ +import type { BaseModel } from "./base"; + +export interface CorrelationIdInterface extends BaseModel {} diff --git a/src/models/info.ts b/src/models/info.ts index 64c97df5a..4bb02e3f7 100644 --- a/src/models/info.ts +++ b/src/models/info.ts @@ -1,7 +1,6 @@ import type { ContactInterface } from "./contact"; import type { LicenseInterface } from "./license"; import type { BaseModel } from "./base"; - import type { DescriptionMixinInterface, ExtensionsMixinInterface, ExternalDocumentationMixinInterface, TagsMixinInterface } from "./mixins"; export interface InfoInterface extends BaseModel, DescriptionMixinInterface, ExtensionsMixinInterface, ExternalDocumentationMixinInterface, TagsMixinInterface { diff --git a/src/models/license.ts b/src/models/license.ts index b98f88e2a..42e254961 100644 --- a/src/models/license.ts +++ b/src/models/license.ts @@ -1,5 +1,4 @@ import type { BaseModel } from "./base"; - import type { ExtensionsMixinInterface } from "./mixins"; export interface LicenseInterface extends BaseModel, ExtensionsMixinInterface { diff --git a/src/models/message-example.ts b/src/models/message-example.ts new file mode 100644 index 000000000..273f24b1c --- /dev/null +++ b/src/models/message-example.ts @@ -0,0 +1,3 @@ +import type { BaseModel } from "./base"; + +export interface MessageExample extends BaseModel {} diff --git a/src/models/message-trait.ts b/src/models/message-trait.ts new file mode 100644 index 000000000..b148318c0 --- /dev/null +++ b/src/models/message-trait.ts @@ -0,0 +1,3 @@ +import type { BaseModel } from "./base"; + +export interface MessageTraitInterface extends BaseModel {} diff --git a/src/models/message-traits.ts b/src/models/message-traits.ts new file mode 100644 index 000000000..3730bbde7 --- /dev/null +++ b/src/models/message-traits.ts @@ -0,0 +1,4 @@ +import type { Collection } from "./collection"; +import type { MessageTraitInterface } from "./message-trait"; + +export interface MessagesTraitsInterface extends Collection {} \ No newline at end of file diff --git a/src/models/message.ts b/src/models/message.ts new file mode 100644 index 000000000..25c764a1f --- /dev/null +++ b/src/models/message.ts @@ -0,0 +1,4 @@ +import type { BaseModel } from "./base"; +import type { MessageTraitInterface } from "./message-trait"; + +export interface MessageInterface extends BaseModel, MessageTraitInterface {} diff --git a/src/models/messages.ts b/src/models/messages.ts new file mode 100644 index 000000000..c48a45dab --- /dev/null +++ b/src/models/messages.ts @@ -0,0 +1,4 @@ +import type { Collection } from "./collection"; +import type { MessageInterface } from "./message"; + +export interface MessagesInterface extends Collection {} \ No newline at end of file diff --git a/src/models/operation-trait.ts b/src/models/operation-trait.ts new file mode 100644 index 000000000..fe7ca9039 --- /dev/null +++ b/src/models/operation-trait.ts @@ -0,0 +1,3 @@ +import type { BaseModel } from "./base"; + +export interface OperationTraitInterface extends BaseModel {} diff --git a/src/models/operation-traits.ts b/src/models/operation-traits.ts new file mode 100644 index 000000000..31e8bcc8f --- /dev/null +++ b/src/models/operation-traits.ts @@ -0,0 +1,4 @@ +import type { Collection } from "./collection"; +import type { OperationTraitInterface } from "./operation-trait"; + +export interface OperationsTraitsInterface extends Collection {} \ No newline at end of file diff --git a/src/models/operation.ts b/src/models/operation.ts new file mode 100644 index 000000000..5eeaaef04 --- /dev/null +++ b/src/models/operation.ts @@ -0,0 +1,4 @@ +import type { BaseModel } from "./base"; +import type { OperationTraitInterface } from "./operation-trait"; + +export interface OperationInterface extends BaseModel, OperationTraitInterface {} diff --git a/src/models/operations.ts b/src/models/operations.ts new file mode 100644 index 000000000..199e19e85 --- /dev/null +++ b/src/models/operations.ts @@ -0,0 +1,4 @@ +import type { Collection } from "./collection"; +import type { OperationInterface } from "./operation"; + +export interface OperationsInterface extends Collection {} \ No newline at end of file diff --git a/src/models/schema.ts b/src/models/schema.ts new file mode 100644 index 000000000..5a8af5d6e --- /dev/null +++ b/src/models/schema.ts @@ -0,0 +1,3 @@ +import type { BaseModel } from "./base"; + +export interface SchemaInterface extends BaseModel {} diff --git a/src/models/schemas.ts b/src/models/schemas.ts new file mode 100644 index 000000000..394fd6552 --- /dev/null +++ b/src/models/schemas.ts @@ -0,0 +1,4 @@ +import type { Collection } from "./collection"; +import type { SchemaInterface } from "./schema"; + +export interface SchemasInterface extends Collection {} diff --git a/src/models/server-variable.ts b/src/models/server-variable.ts index 0f49d4150..906b7063a 100644 --- a/src/models/server-variable.ts +++ b/src/models/server-variable.ts @@ -1,11 +1,11 @@ -import {BaseModel} from './base'; -import { DescriptionMixinInterface, ExtensionsMixinInterface } from './mixins'; +import type { BaseModel } from './base'; +import type { DescriptionMixinInterface, ExtensionsMixinInterface } from './mixins'; export interface ServerVariableInterface extends BaseModel, DescriptionMixinInterface, ExtensionsMixinInterface { - id(): string; - hasDefaultValue(): boolean; - defaultValue(): string | undefined; - hasAllowedValue(): boolean; - allowedValue(): any[] - examples(): Array -} \ No newline at end of file + id(): string; + hasDefaultValue(): boolean; + defaultValue(): string | undefined; + hasAllowedValue(): boolean; + allowedValue(): Array; + examples(): Array; +} diff --git a/src/models/server-variables.ts b/src/models/server-variables.ts index 4a908a830..3438381c1 100644 --- a/src/models/server-variables.ts +++ b/src/models/server-variables.ts @@ -1,4 +1,4 @@ -import { Collection } from './collection'; -import { ServerVariableInterface } from './server-variable'; +import type { Collection } from './collection'; +import type { ServerVariableInterface } from './server-variable'; export interface ServerVariablesInterface extends Collection { } \ No newline at end of file diff --git a/src/models/server.ts b/src/models/server.ts index 92bfc0050..5f673b886 100644 --- a/src/models/server.ts +++ b/src/models/server.ts @@ -1,6 +1,6 @@ import type { BaseModel } from "./base"; import type { BindingsMixinInterface, DescriptionMixinInterface, ExtensionsMixinInterface } from './mixins'; -import { ServerVariablesInterface } from "./server-variables"; +import type { ServerVariablesInterface } from "./server-variables"; export interface ServerInterface extends BaseModel, DescriptionMixinInterface, BindingsMixinInterface, ExtensionsMixinInterface { id(): string diff --git a/src/models/servers.ts b/src/models/servers.ts index d8360d487..23b9a33e3 100644 --- a/src/models/servers.ts +++ b/src/models/servers.ts @@ -1,4 +1,4 @@ -import { Collection } from "./collection"; -import {ServerInterface} from "./server"; +import type { Collection } from "./collection"; +import type { ServerInterface } from "./server"; export interface ServersInterface extends Collection {} \ No newline at end of file diff --git a/src/models/utils.ts b/src/models/utils.ts index c97451818..2da3454f4 100644 --- a/src/models/utils.ts +++ b/src/models/utils.ts @@ -33,13 +33,3 @@ function mixin(derivedCtor: any, constructors: any[]): typeof BaseModel { }); return derivedCtor; } - -export function createArrayFromMap(json: Record){ - const ArrayObject = []; - for (const [key, value] of Object.entries(json)) { - value['id'] = key; - ArrayObject.push(value); - }; - - return ArrayObject; -} \ No newline at end of file