How to generate connector for World Bank API using Ballerina OpenAPI tool #102
Replies: 3 comments
-
Issue related to Ballerina is discussed here |
Beta Was this translation helpful? Give feedback.
-
As discussed offline, It is nice to have a second approach because its OAS concept is directly mapping correctly to ballerina concepts as well. But as we figured out, OAS uses Considering advantage and disadvantages of both approaches in the OpenAPI tool perspective, if we can provide support first to the first approach would be really helpful to other connectors with array type with |
Beta Was this translation helpful? Give feedback.
-
As we identified during the offline discussion, approach one would be a bit complex to understand by the ordinary programmer. The main problem is to cast to the exact data type he wanted before accessing the fields. In that aspect, the second approach seems more appealing, and we should support it when the parser is updated to swagger 3.1. We should stick to the current implementation until that. The only change to address is that the previously optional fields to required by looking at the API response. |
Beta Was this translation helpful? Give feedback.
-
The response payload structure of World Bank API is an heterogeneous array which includes two elements. First element is a record. second element is an array of another record type.
Ex:
To map the response payload to a Ballerina type there are two approaches.
Suggested OpenAPI schema
Suggested types generation
Generating an array type like
CountryPopulationResponse
is not yet supported by the Ballerina OpenAPI tool.Suggested remote function generation
However this approach returns an error
Sample code to access data
Following the standard given in OpenAPI specification 3.1, schema of a tuple can be defined as below.
Suggested types generation
Generating a tuple from OpenAPI schema is not yet supported by Ballerina OpenAPI tool (Not supporting OpenAPI Spec 3.1)
Suggested remote function generation
However this approach returns an error
Sample code to access data
Conclusion
Approach 1
Approach 2
@indikasampath2000 @abeykoon @lnash94 Appreciate your inputs
Beta Was this translation helpful? Give feedback.
All reactions