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

refactor: add all missed interfaces #538

Merged
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
3 changes: 3 additions & 0 deletions src/models/channel-parameter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { BaseModel } from "./base";

export interface ChannelParameterInterface extends BaseModel {}
4 changes: 4 additions & 0 deletions src/models/channel-parameters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { Collection } from "./collection";
import type { ChannelParameterInterface } from "./channel-parameter";

export interface ChannelParametersInterface extends Collection<ChannelParameterInterface> {}
3 changes: 3 additions & 0 deletions src/models/channel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { BaseModel } from "./base";

export interface ChannelInterface extends BaseModel {}
4 changes: 4 additions & 0 deletions src/models/channels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { Collection } from "./collection";
import type { ChannelInterface } from "./channel";

export interface ChannelsInterface extends Collection<ChannelInterface> {}
4 changes: 2 additions & 2 deletions src/models/collection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { BaseModel } from "./base";

export abstract class Collection<T extends BaseModel> extends Array<T> {
export abstract class Collection<T extends BaseModel | Collection<any>> extends Array<T> {
constructor(
protected readonly collections: T[]
) {
Expand All @@ -17,4 +17,4 @@ export abstract class Collection<T extends BaseModel> extends Array<T> {
isEmpty(): boolean {
return this.collections.length === 0;
}
}
}
32 changes: 32 additions & 0 deletions src/models/components.ts
Original file line number Diff line number Diff line change
@@ -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<CorrelationIdInterface>;
securitySchemes(): any; // TODO: Fix type after merging Souvik PR
serverBindings(): Collection<BindingsInterface>;
channelBindings(): Collection<BindingsInterface>;
operationBindings(): Collection<BindingsInterface>;
messageBindings(): Collection<BindingsInterface>;
}
1 change: 0 additions & 1 deletion src/models/contact.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { BaseModel } from "./base";

import type { ExtensionsMixinInterface } from "./mixins";

export interface ContactInterface extends BaseModel, ExtensionsMixinInterface {
Expand Down
3 changes: 3 additions & 0 deletions src/models/correlation-id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { BaseModel } from "./base";

export interface CorrelationIdInterface extends BaseModel {}
1 change: 0 additions & 1 deletion src/models/info.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/models/license.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { BaseModel } from "./base";

import type { ExtensionsMixinInterface } from "./mixins";

export interface LicenseInterface extends BaseModel, ExtensionsMixinInterface {
Expand Down
3 changes: 3 additions & 0 deletions src/models/message-example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { BaseModel } from "./base";

export interface MessageExample extends BaseModel {}
3 changes: 3 additions & 0 deletions src/models/message-trait.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { BaseModel } from "./base";

export interface MessageTraitInterface extends BaseModel {}
4 changes: 4 additions & 0 deletions src/models/message-traits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { Collection } from "./collection";
import type { MessageTraitInterface } from "./message-trait";

export interface MessagesTraitsInterface extends Collection<MessageTraitInterface> {}
4 changes: 4 additions & 0 deletions src/models/message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { BaseModel } from "./base";
import type { MessageTraitInterface } from "./message-trait";

export interface MessageInterface extends BaseModel, MessageTraitInterface {}
4 changes: 4 additions & 0 deletions src/models/messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { Collection } from "./collection";
import type { MessageInterface } from "./message";

export interface MessagesInterface extends Collection<MessageInterface> {}
3 changes: 3 additions & 0 deletions src/models/operation-trait.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { BaseModel } from "./base";

export interface OperationTraitInterface extends BaseModel {}
4 changes: 4 additions & 0 deletions src/models/operation-traits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { Collection } from "./collection";
import type { OperationTraitInterface } from "./operation-trait";

export interface OperationsTraitsInterface extends Collection<OperationTraitInterface> {}
4 changes: 4 additions & 0 deletions src/models/operation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { BaseModel } from "./base";
import type { OperationTraitInterface } from "./operation-trait";

export interface OperationInterface extends BaseModel, OperationTraitInterface {}
4 changes: 4 additions & 0 deletions src/models/operations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { Collection } from "./collection";
import type { OperationInterface } from "./operation";

export interface OperationsInterface extends Collection<OperationInterface> {}
3 changes: 3 additions & 0 deletions src/models/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { BaseModel } from "./base";

export interface SchemaInterface extends BaseModel {}
4 changes: 4 additions & 0 deletions src/models/schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { Collection } from "./collection";
import type { SchemaInterface } from "./schema";

export interface SchemasInterface extends Collection<SchemaInterface> {}
18 changes: 9 additions & 9 deletions src/models/server-variable.ts
Original file line number Diff line number Diff line change
@@ -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<string>
}
id(): string;
hasDefaultValue(): boolean;
defaultValue(): string | undefined;
hasAllowedValue(): boolean;
allowedValue(): Array<string>;
examples(): Array<string>;
}
4 changes: 2 additions & 2 deletions src/models/server-variables.ts
Original file line number Diff line number Diff line change
@@ -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<ServerVariableInterface> { }
2 changes: 1 addition & 1 deletion src/models/server.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/models/servers.ts
Original file line number Diff line number Diff line change
@@ -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<ServerInterface> {}
10 changes: 0 additions & 10 deletions src/models/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,3 @@ function mixin(derivedCtor: any, constructors: any[]): typeof BaseModel {
});
return derivedCtor;
}

export function createArrayFromMap(json: Record<string,any>){
const ArrayObject = [];
for (const [key, value] of Object.entries(json)) {
value['id'] = key;
ArrayObject.push(value);
};

return ArrayObject;
}