We have changed the structure of the SDK to break cyclic dependencies. Due to this, the following changes have been made:
- Model deserialization logic has moved out from model classes.
- We have added new files
ModelFactory.jsto the sdk.
- Exception handling in
BaseControllerhas changed to use
BaseModelis now being used to assign values to model properties (when model class is directly instantiated)
BaseControlleris not being exposed by the API Client now.
Please generate your SDK again to get the improved code.
- Previously, models were being imported in other model classes because model deserialization was done inside the model class. This caused cyclic dependencies in some cases. To break this cyclic dependency, we have changed the structure of model classes, exception classes and added
ModelFactoryclasses alongwith changes to
ObjectMapperclass is now being used for mapping the model fields with their appropriate values. Object Mapper expects a json object (containing the input values to be assigned) and the name of the model to be instantiated. It then maps the input json object with the fields of the model and assigns them the correct value.
- Model instantiation has now moved to
ModelFactory.jsclass. Previously, controllers directly instantiated models. However, now controllers get a mapped object for the model from the
Model Factoryto get an instance of the model/exception and then returns the mapped object (with correct values assigned to properties).
- Previously, properties of a model object were deserialized (or mapped with their corresponding values) inside the model class itself. This behavior has changed now. Model classes do not deserialize the object themselves. There are 2 cases: We still allow users to create instances of models and pass in an object. In this case, the correct value for a model field is gotten from the object (if it is defined). However, if a model is instantiated using the model factory (as is done in the controllers now), then model deserialization will be handled by the
Datetimedeserialization is also being handled by the
- We are now maintaining a mapping object in model and exception files which contains information about the properties of the models/exceptions.
BaseModel.jsfile has now changed. It uses
mappingInfoof a model class to check if it has additional properties. Previously, a variable called
_variableDictwas being used for storing details of additional model properties.
- Global error handling logic in BaseController has changed. BaseController does not directly create instances of Exception classes. Instead,
ObjectMapperare being used for instantiating and deserializing Exception classes.