We have changed the structure of the Angular SDK to break cyclic dependencies. Due to this, the following changes have been made:
- Model deserialization logic has moved out from model files.
- We have added new files
ObjectMapper.js
andModelFactory.js
to the SDK. BaseModel
is now being used to assign values to model properties (when model class is directly instantiated)BaseController
has been added to the SDK.
Please generate your SDK again to get the improved code.
Detailed Changes
- Previously, models were being imported in other model files because model deserialization was done inside the model files. This caused cyclic dependencies in some cases. To break this cyclic dependency, we have changed the structure of model classes and added
ObjectMapper
andModelFactory
files alongwith changes toControllers
andBaseModel
files as well as addition ofBaseController
file. ObjectMapper
service is now being used for mapping the model fields with their appropriate values.- Model instantiation has now moved to
ModelFactory.js
service. Previously, controllers directly instantiated models. - Previously, properties of a model object were deserialized (or mapped with their corresponding values) inside the model file itself. This behavior has changed now. Model files 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). So the correct object needs to be passed in the constructor (with the right property names and values). 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
ObjectMapper
service. - We are now maintaining a mapping object in model files which contains information about the properties of the models/exceptions.
- The
toJSON
function inBaseModel.js
has been updated according to the mappingInfo addition in model files. BaseController
has been added to the SDK now. BaseController returns an instance of theObjectMapper
service.