Introduce a ballerina openapi extension for simple data mapping scenarios. When creating ballerina client connectors. There can be instances where the request payload type is complex. We can add a mapping layer on top of the client to define more user-friendly types.
Goals
Introduce ballerina openapi extension to data mapping layer which can then be generated with minimal code changes.
Motivation
Even if only changes to the openapi spec is introducing only minimal additions to the code base on top of code generation
Description
requestBody:
x-ballerina-request:
schema:
$ref: "#/components/schemas/EmailMessage"
description: The message to be sent.
content:
application/json:
schema:
$ref: "#/components/schemas/Message"
responses:
"200":
x-ballerina-response:
schema:
$ref: "#/components/schemas/EmailMessage"
content:
application/json:
schema:
$ref: "#/components/schemas/Message"
description: Successful response
With the above definition generator client can generate both EmailMessage and Message ballerina types.
Here additionally, user has to add the conversion utils. This is additional to the generated client.
Alternatives
Use a wrapper client to wrap the generated client. More information
This is still under development as we have to sort out the issue of user giving conversion code in the definition itself. If the developer can give the mapping the entire code can be generated
Summary
Introduce a ballerina openapi extension for simple data mapping scenarios. When creating ballerina client connectors. There can be instances where the request payload type is complex. We can add a mapping layer on top of the client to define more user-friendly types.
Goals
Introduce ballerina openapi extension to data mapping layer which can then be generated with minimal code changes.
Motivation
Even if only changes to the openapi spec is introducing only minimal additions to the code base on top of code generation
Description
With the above definition generator client can generate both
EmailMessage
andMessage
ballerina types.Here additionally, user has to add the conversion utils. This is additional to the generated client.
Alternatives
Use a wrapper client to wrap the generated client. More information