Hi all,

When publishing to external stores, at runtime we need to use API create,
life-cycle change, create a version, add API thumbnail, delete Publisher
REST APIs. In order to create the API payload, we need to do the mapping
from API object to APIDTO. Reusing the existing APIDTO or APIMappingUtil
classes are not possible as we do not import rest.api dependencies to impl
level. Creating the payload manually from scratch will not be a very
cleaner approach, also we will be duplicating the same logic.

Hence following are the options which might help us to achieve this.

   - Generate a REST client using publisher REST API swagger (using
   openapi-generator plugin) and pack it as a jar in the product (packing the
   component inside service-stubs). But for that, we need to pack an
   additional set of dependencies to lib as well. For example, the generated
   client is using okhttp client. We also need to add the APIMappingUtil logic
   (to map API to DTO) as util class inside the same client.


   - Generate only the DTO classes using publisher REST API swagger and
   pack it as a jar in service-stubs. However, even in this case, API to DTO
   object mapping will need to be defined separately in the same service
   client. Conversion from DTO to JSON and invoking the HTTP client need to be
   handled in WSO2APIPublisher code.


   - Use import-export webapp, to import the API and modify the api.json to
   include the artifact properties apiOwner, advertiseOnly, redirectURL, zip,
   and export it to the external Store. A separate REST API call to change the
   lifecycle of the API to "Published" state, needs to be done.

One of the main drawbacks of the first two options is maintaining the DTO,
Mapping logic in two different places whenever we do a change to the REST
API. Appreciate your response on this regard.

Thanks

*Dushani Wellappili*
Software Engineer - WSO2

Email : dusha...@wso2.com
Mobile : +94779367571
Web : https://wso2.com/
_______________________________________________
Architecture mailing list
Architecture@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to