Skip to content

Commit

Permalink
refactor: stop with v3 implementation (asyncapi#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
magicmatatjahu committed Oct 3, 2022
1 parent 6bf2d35 commit e7e02fa
Show file tree
Hide file tree
Showing 20 changed files with 5 additions and 643 deletions.
5 changes: 2 additions & 3 deletions src/models/asyncapi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AsyncAPIDocumentV2 } from "./v2";
import { AsyncAPIDocumentV3 } from "./v3";

import type { InfoInterface } from "./info";
import type { BaseModel } from "./base";
Expand All @@ -17,8 +16,8 @@ export function newAsyncAPIDocument(asyncapi: DetailedAsyncAPI): AsyncAPIDocumen
switch (asyncapi.semver.major) {
case 2:
return new AsyncAPIDocumentV2(asyncapi.parsed, { asyncapi, pointer: '/' });
case 3:
return new AsyncAPIDocumentV3(asyncapi.parsed, { asyncapi, pointer: '/' });
// case 3:
// return new AsyncAPIDocumentV3(asyncapi.parsed, { asyncapi, pointer: '/' }) as any;
default:
throw new Error(`Unsupported AsyncAPI version: ${asyncapi.semver.version}`);
}
Expand Down
26 changes: 1 addition & 25 deletions src/models/v3/asyncapi.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
import { BaseModel } from "../base";
import { Info } from "./info";
import { Servers } from "./servers";
import { Server } from "./server";

import { Mixin } from '../utils';
import { ExtensionsMixin } from './mixins/extensions';

import type { AsyncAPIDocumentInterface, InfoInterface } from "../../models";
import type { ServersInterface } from "models/servers";

export class AsyncAPIDocument
extends Mixin(BaseModel, ExtensionsMixin)
implements AsyncAPIDocumentInterface {

export class AsyncAPIDocument extends BaseModel {
version(): string {
return this._json.asyncapi;
}

info(): InfoInterface {
return this.createModel(Info, this._json.info, { pointer: '/info' });
}

servers(): ServersInterface {
return new Servers(
Object.entries(this._json.servers).map(([serverName, server]) =>
this.createModel(Server, server, { id: serverName, pointer: `/servers/${serverName}` })
)
);
}
}
32 changes: 0 additions & 32 deletions src/models/v3/contact.ts

This file was deleted.

17 changes: 1 addition & 16 deletions src/models/v3/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
export { AsyncAPIDocument as AsyncAPIDocumentV3 } from './asyncapi';
export { Contact as ContactV3 } from './contact';
export { Info as InfoV3 } from './info';
export { License as LicenseV3 } from './license';
export { Bindings as BindingsV3, Binding as BindingV3 } from './mixins/bindings';
export { Extensions as ExtensionsV3, Extension as ExtensionV3 } from './mixins/extensions';
export { ExternalDocumentation as ExternalDocumentationV3 } from './mixins/external-docs';
export { Tags as TagsV3, Tag as TagV3 } from './mixins/tags';
export { Server as ServerV3 } from './server';
export { Servers as ServersV3 } from './servers';
export { SecurityScheme as SecuritySchemeV3 } from './security-scheme';
export { SecuritySchemes as SecuritySchemesV3 } from './security-schemes';
export { ServerVariable as ServerVariableV3 } from './server-variable';
export { ServerVariables as ServerVariablesV3 } from './server-variables';
export {OAuthFlow as OAuthFlowV3} from './oauth-flow';
export {OAuthFlows as OAuthFlowsV3} from './oauth-flows';
export { AsyncAPIDocument as AsyncAPIDocumentV3 } from './asyncapi';
76 changes: 0 additions & 76 deletions src/models/v3/info.ts

This file was deleted.

20 changes: 0 additions & 20 deletions src/models/v3/license.ts

This file was deleted.

55 changes: 0 additions & 55 deletions src/models/v3/mixins/bindings.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/models/v3/mixins/description.ts

This file was deleted.

55 changes: 0 additions & 55 deletions src/models/v3/mixins/extensions.ts

This file was deleted.

30 changes: 0 additions & 30 deletions src/models/v3/mixins/external-docs.ts

This file was deleted.

37 changes: 0 additions & 37 deletions src/models/v3/mixins/tags.ts

This file was deleted.

Loading

0 comments on commit e7e02fa

Please sign in to comment.