-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restructure Ballerina resource path parameters to OAS module #5816
Comments
Meeting date: 27/11/2023 Had a discussion on the above concerns regarding rest parameters in the resource path and came up with the following decisions: Ballerina service to OAS
resource function get albums/[string... title]() {} paths:
/albums/*:
get:
operationId: getAlbumsTitle
responses:
"202":
description: Accepted
OAS to Ballerina service
|
OAS3 does not have a notion of "wildcard path" for PathItems, so this description document will not work for anything outside of ballerina. Why not just serialize (string) array parameters in a OAS3 standardized way instead? |
@commonism thanks for the clarification regarding "wildcard path" limitation in OAS3. We initially considered parameter serialization as a workaround. But found that none of the supported encodings aligns with our specific scenario: @shafreenAnfar @lnash94 as discussed, we will omit mapping of the entire operation if there is a rest parameter in the resource path and provide users with a warning since we have a limitation with the "wildcard path" in OAS3. |
I'm with the client side of the OpenAPI ecosystem, and I really encourage you to design ballerina REST encoding compliant to the OAI specification. Non compliant will result in "can not be used with any existing tooling and requires manual intervention for data serialization/validation". There is no alternative to OAI, not being compatible as a web/rest framework begs many questions wrt. to the design decisions and the relevance of the framework. |
Fixed via ballerina-platform/openapi-tools#1564 |
Description:
Need to restructure the code base of resource path parameter mapping from Ballerina to OpenAPI specification.
Parent: #5055
When the code is properly restructured, the resource path parameters are reflected in the OpenAPI specification as follows,
Sample Ballerina code:
OpenAPI specification:
Rest parameters in the resource path:
Ballerina supports rest parameters. There cannot be another parameter after a rest parameter in the resource path.
Utilizing rest parameters in the path of a resource function acts as a list. For example:
This allows us to send a request like:
GET users/id1/id2/id3
In the resulting URL, these parameters are concatenated with
%2F
(encoded value for/
), and it looks like:http://{hostName}:{port}/users/id1%2Fid2%2Fid3
Parameter serialization is used in OpenAPI specification to support arrays and objects in operation parameters (path, query, header, and cookie) and lets you specify how these parameters should be serialized. The serialization method is defined by the
style
andexplode
keywords.After having some discussions, we decided to omit the mapping of the entire operation for now if there is a rest parameter in the resource path and provide users with a warning since we cannot properly reflect rest parameters in the OpenAPI specification!
The text was updated successfully, but these errors were encountered: