- Optimizer
this class is the starting point of the library. user will only interact with this class. here we generate different kind of reports using optimizers, apply changes and return the results to the user.
- findAllComponents(optimizableComponentGroup) ⇒
- findDuplicateComponents(optimizableComponentGroup) ⇒
- hasParent()
Checks if a component's parent is a ref or not.
- isEqual(component1, component2, referentialEqualityCheck) ⇒
- isInComponents()
checks if a component is located in
components
section of an asyncapi document.- isInChannels()
checks if a component is located in
channels
section of an asyncapi document.- toJS()
Converts JSON or YAML string object.
- Rules :
Object
- DisableOptimizationFor :
Object
- Options :
Object
this class is the starting point of the library. user will only interact with this class. here we generate different kind of reports using optimizers, apply changes and return the results to the user.
Kind: global class
Access: public
- Optimizer
- new Optimizer(YAMLorJSON)
- .getReport() ⇒
Report
- .getOptimizedDocument([Options]) ⇒
string
Param | Type | Description |
---|---|---|
YAMLorJSON | any |
YAML or JSON document that you want to optimize. You can pass Object, YAML or JSON version of your AsyncAPI document here. |
Kind: instance method of Optimizer
Returns: Report
- an object containing all of the optimizations that the library can do.
This function is used to get the optimized document after seeing the report.
Kind: instance method of Optimizer
Returns: string
- returns an stringified version of the YAML output.
Param | Type | Description |
---|---|---|
[Options] | Options |
the options are a way to customize the final output. |
Kind: global function
Returns: A list of optimization report elements.
Param | Description |
---|---|
optimizableComponentGroup | all AsyncAPI Specification-valid components. |
Kind: global function
Returns: A list of optimization report elements.
Param | Description |
---|---|
optimizableComponentGroup | all AsyncAPI Specification-valid components that you want to analyze for duplicates. |
Checks if a component's parent is a ref or not.
Kind: global function
Returns: whether the two components are equal.
Param | Description |
---|---|
component1 | The first component that you want to compare with the second component. |
component2 | The second component. |
referentialEqualityCheck | If true the function will return true if the two components have referential equality OR they have the same structure. If false the it will only return true if they have the same structure but they are NOT referentially equal. |
checks if a component is located in components
section of an asyncapi document.
checks if a component is located in channels
section of an asyncapi document.
Converts JSON or YAML string object.
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[reuseComponents] | Boolean |
whether to reuse components from components section or not. Defaults to true . |
[removeComponents] | Boolean |
whether to remove un-used components from components section or not. Defaults to true . |
[moveAllToComponents] | Boolean |
whether to move all AsyncAPI Specification-valid components to the components section or not. Defaults to true . |
[moveDuplicatesToComponents] | Boolean |
whether to move duplicated components to the components section or not. Defaults to false . |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[schema] | Boolean |
whether object schema should be excluded from the process of optimization (true instructs not to add calculated schemas to the optimized AsyncAPI Document.) |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[rules] | Rules |
the list of rules that specifies which type of optimizations should be applied. |
[output] | String |
specifies which type of output user wants, 'JSON' or 'YAML' . Defaults to 'YAML' ; |
[disableOptimizationFor] | DisableOptimizationFor |
the list of objects that should be excluded from the process of optimization. |