eclipse-esmf / esmf-sdk

Load Aspect Models and their artifacts as Java code; share components to realize SAMM as code
https://eclipse-esmf.github.io/esmf-developer-guide/index.html
Mozilla Public License 2.0
22 stars 13 forks source link

[Request] Add functionality to support exports to other types of APIs. Example: AsyncAPI #452

Closed Kostadin-Ivanov closed 3 months ago

Kostadin-Ivanov commented 9 months ago

Is your task related to a problem? Please describe. For our projects, we want to create standard models for general RESTful APIs and AsyncAPIs. Currently we can use only exports to OpenAPI which as described in request: [Request] Add customization of OpenAPI exports is quite Digital Twin Registry focused.y

Could we have option to support other types of APIs by the API generation functionality. An example would be AsyncAPIs.

Describe the solution you'd like Best option would be if a user can provide some king of an API template and then SDK can build corresponding API, either OpenAPI, AsyncAPI or others, based on this template. Other solution would be if the export functionality, has a parameter: --api-type or similar which user can use to set the required API type from a list with supported APIs.

Describe alternatives you've considered N/A

Additional context Not available, but if required we can further discuss this and eventual implementation.

chris-volk commented 4 months ago

Dear @Kostadin-Ivanov , we have now designed the solution that we will implement: The java SDK will support AsyncAPI with MQTT using one topic per Aspect since Aspects are modular and the right standard "level of scope" for a topic. The topic structure will be well-defined to allow a hard-coded generation and easy tool support and let clients rely on this standard structure. The supported message format will be JSON only to reuse the existing SAMM JSON payload mapping in close alignment with the existing OpenAPI spec generation. Due to a lack of necessity, we will, at least initially, not realize the AsyncAPI concept of Operations, which could in the future be mapped to SAMM operations. For each message, a SAMM Event will be required so that it is possible to generate AsyncAPI in a unique way from the Aspect Model. Please note that this approach is flexible and covers very case:

Event triggers

Can be defined as required, e.g. onChange/interval based/other triggers

Payload choices

Can be defined as required, see as follows with example diagrams from the Movement example

publication of Events via Aspect Model

With this approach, it is required to model Events before using AsyncAPIs in a conformant way, however this is still a flexible approach:

github-actions[bot] commented 3 months ago

Release v2.7.0 addresses this.