Hi all,

We are in the process of implementing RESTful API for API Manager
functionalities.
[1] contains a draft version of the API definition.

Above mentioned API definition contains models for different elements
manipulated by API Manager such as api, document, tier etc (Please refer
Models section of [1]). Those elements do not have 1:1 mapping with the
models we have defined inside carbon-apimgt models [2].

For an example, following is the mapping between some of the properties in
API model defined in RESTful service [1] and
org.wso2.carbon.apimgt.api.model.API

API model properties defined in RESTful service

Get methods for retrieving corresponding property values from carbon-apimgt
API model

context

API.getContext()

endpoint

API.getEndpointConfig()

isDefaultVersion

API.isDefaultVersion()

name

API.getId().getApiName()

provider

API.getId().getProviderName()

responseCaching

API.getResponseCache()

swagger

APIDefinitionFromSwagger20

.getAPIDefinition(api.getId(), registry) - This property is not available
in API model

Models defined in RESTful service are in a more readable manner than models
in carbon-apimgt. Because models in carbon-apimgt are designed mainly
aiming at implementation aspects.

Mapping between those two models is essential when communicating APIManager
functionalities in RESTful manner.
Several options can be used for the mapping.

*Option 1*
Using a hash map for the mapping between those two models.

*Option 2*
Make two models compatible for reflection. At the moment it cannot be
applied due to the differences among property names in those two models.

*Option 3*
Using a library which is capable of doing the mapping between those two
models.
Since JSON is a widely used format for passing content through web
services, I looked at several JSON parsing libraries for converting models.
Libraries such as GSON, Jackson etc. are capable of doing complete
conversion of API model in carbon-apimgt to JSON.
But I was unable to find any approach for a mapping between two models.
Annotations can be used as a solution. But maintainability is quite less.

Main consideration regarding this mapping is, it should be easily
maintainable without causing huge burden when changing either model.
Reflection is the most suitable approach in those kind of use cases. But it
cannot be applied here because there is no direct mapping between two
models.

Your suggestions are highly appreciated on a better approach for mapping
those models.

Thank you.

[1] http://hevayo.github.io/restful-apim/
[2]
https://github.com/thilinicooray/carbon-apimgt/tree/master/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model
-- 
Best Regards,

*Thilini Cooray*
Software Engineer
Mobile : +94 (0) 774 570 112 <%2B94%20%280%29%20773%20451194>
E-mail : [email protected]

WSO2 Inc. www.wso2.com
lean.enterprise.middleware
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to