Skip to content

Latest commit

 

History

History
173 lines (129 loc) · 6.31 KB

API.md

File metadata and controls

173 lines (129 loc) · 6.31 KB

Classes

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.

Functions

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.

Typedefs

Rules : Object
DisableOptimizationFor : Object
Options : Object

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.

Kind: global class
Access: public

new Optimizer(YAMLorJSON)

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.

optimizer.getReport() ⇒ Report

Kind: instance method of Optimizer
Returns: Report - an object containing all of the optimizations that the library can do.

optimizer.getOptimizedDocument([Options]) ⇒ string

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.

findAllComponents(optimizableComponentGroup) ⇒

Kind: global function
Returns: A list of optimization report elements.

Param Description
optimizableComponentGroup all AsyncAPI Specification-valid components.

findDuplicateComponents(optimizableComponentGroup) ⇒

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.

hasParent()

Checks if a component's parent is a ref or not.

Kind: global function

isEqual(component1, component2, referentialEqualityCheck) ⇒

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.

isInComponents()

checks if a component is located in components section of an asyncapi document.

Kind: global function

isInChannels()

checks if a component is located in channels section of an asyncapi document.

Kind: global function

toJS()

Converts JSON or YAML string object.

Kind: global function

Rules : 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.

DisableOptimizationFor : Object

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.)

Options : Object

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.