@@ -14,7 +14,7 @@ import { Schemas } from './schemas';
14
14
15
15
import { extensions } from './mixins' ;
16
16
import { tilde } from '../../utils' ;
17
- import { SchemaTypesToIterate , traverseAsyncApiDocument } from '../../iterator ' ;
17
+ import { schemasFromDocument } from '../utils ' ;
18
18
19
19
import type { AsyncAPIDocumentInterface } from '../asyncapi' ;
20
20
import type { InfoInterface } from '../info' ;
@@ -26,12 +26,12 @@ import type { MessageInterface } from '../message';
26
26
import type { ComponentsInterface } from '../components' ;
27
27
import type { SecuritySchemesInterface } from '../security-schemes' ;
28
28
import type { ExtensionsInterface } from '../extensions' ;
29
- import type { SchemaInterface } from '../schema' ;
30
29
import type { SchemasInterface } from '../schemas' ;
30
+ import type { OperationInterface } from '../operation' ;
31
+ import type { ChannelInterface } from '../channel' ;
32
+ import type { ServerInterface } from '../server' ;
33
+
31
34
import type { v3 } from '../../spec-types' ;
32
- import { OperationInterface } from '../operation' ;
33
- import { ChannelInterface } from '../channel' ;
34
- import { ServerInterface } from '../server' ;
35
35
36
36
export class AsyncAPIDocument extends BaseModel < v3 . AsyncAPIObject > implements AsyncAPIDocumentInterface {
37
37
version ( ) : string {
@@ -89,8 +89,8 @@ export class AsyncAPIDocument extends BaseModel<v3.AsyncAPIObject> implements As
89
89
return new Messages ( messages ) ;
90
90
}
91
91
92
- schemas ( ) {
93
- return this . __schemas ( false ) ;
92
+ schemas ( ) : SchemasInterface {
93
+ return schemasFromDocument ( this , Schemas , false ) ;
94
94
}
95
95
96
96
securitySchemes ( ) : SecuritySchemesInterface {
@@ -138,26 +138,10 @@ export class AsyncAPIDocument extends BaseModel<v3.AsyncAPIObject> implements As
138
138
}
139
139
140
140
allSchemas ( ) : SchemasInterface {
141
- return this . __schemas ( true ) ;
141
+ return schemasFromDocument ( this , Schemas , true ) ;
142
142
}
143
143
144
144
extensions ( ) : ExtensionsInterface {
145
145
return extensions ( this ) ;
146
146
}
147
-
148
- private __schemas ( withComponents : boolean ) {
149
- const schemas : Set < SchemaInterface > = new Set ( ) ;
150
- function callback ( schema : SchemaInterface ) {
151
- if ( ! schemas . has ( schema . json ( ) ) ) {
152
- schemas . add ( schema ) ;
153
- }
154
- }
155
-
156
- let toIterate = Object . values ( SchemaTypesToIterate ) ;
157
- if ( ! withComponents ) {
158
- toIterate = toIterate . filter ( s => s !== SchemaTypesToIterate . Components ) ;
159
- }
160
- traverseAsyncApiDocument ( this , callback , toIterate ) ;
161
- return new Schemas ( Array . from ( schemas ) ) ;
162
- }
163
147
}
0 commit comments