[Proposal] Convert the OAS to Ballerina-friendly naming conventions #6867
Labels
Area/OpenapiToBallerina
module/openapi-tools
Status/Active
Proposals that are under review
Type/NewFeature
Type/Proposal
Milestone
Summary
The OpenAPI Specification (OAS) is a widely adopted standard for defining RESTful APIs. However, the naming conventions used in OAS often differ from those preferred in Ballerina. To enhance the usability and readability of OAS definitions in Ballerina, it is essential to adapt the OAS naming conventions to align with Ballerina's conventions. This proposal outlines the approach for modifying the OAS to conform to Ballerina naming conventions.
Goals
Motivation
[1] Referring to the below OAS sample:
karbon.Api.Contacts.V2.ClientGroupSummaryDTO
is hard to understand and doesn't follow Ballerina's naming rules.full-name
, andphone-number
in the object, which also don't match Ballerina's naming style.Generated Ballerina Code:
However, when using this generated record, users may face code readability issues. The escaped characters make the code harder to read and understand. This can lead to confusion and potential mistakes during development.
By addressing this issue we aim to generate Ballerina-friendly code using OAS by applying modifications to the user-given OAS.
Description
The proposed solution is modifying the OAS with the Ballerina-friendly naming conventions for the below-mentioned areas,
x-ballerina-name
to the OAS query parameters and OAS property names[2] Modified OAS for above sample[1]:
We are providing two options to the user as a deliverable,
@http:Field
is used for data binding with actual payload, the proposal can be found here. This annotation value will populate using the extensions we have mentioned in the above extension details section. This annotation allows users to define custom names for fields when they are serialized to OAS.@http:Query
annotation is used to capture the query parameter name modification in client/service generationAnnotation implementation more details can be found here : [Proposal]: Data binding annotations for custom and actual names in Ballerina fields and resource/remote parameters #6747
The text was updated successfully, but these errors were encountered: