ballerina-lang
ballerina-lang copied to clipboard
[Bug]: Service object type from the service object typedesc does not have the annotations
Description
When we get the service object type from the service object typedesc, the annotations at the service level, resource level and resource parameter level are not visible at runtime
Steps to Reproduce
I have the following service object type:
@http:ServiceContractConfig {
basePath: "/social-media"
}
@http:ServiceConfig {
auth: [
{
fileUserStoreConfig: {},
scopes: ["admin"]
}
]
}
public type Service service object {
*http:ServiceContract;
...
@http:ResourceConfig {
name: "user",
linkedTo: [
{name: "user", method: http:DELETE, relation: "delete-user"},
{name: "posts", method: http:POST, relation: "create-posts"},
{name: "posts", method: http:GET, relation: "get-posts"}
]
}
resource function get users/[int id](@http:Header string X\-API\-Version) returns @http:Payload {mediaType: "application/org+json"} User|UserNotFound|error;
...
}
Here, I have annotations at service level, resource level and resource parameter level. I pass the typedesc of this service via an annotation - field name serviceType:
@http:ServiceConfig {
serviceType: Service
}
service Service "/social-media" on new http:Listener(8080) {
...
resource function get users/[int id]() returns socialMedia:User|socialMedia:UserNotFound|error {
return {id: 1, name: "John Doe", email: "[email protected]"};
}
...
}
At runtime, I can get the service object type as follows:
BTypedesc -> ReferenceType -> ServiceType (using TypeUtils APIs)
In that service type, none of the annotations are visible
Affected Version(s)
Ballerina SwanLake Update 9
OS, DB, other environment details and versions
No response
Related area
-> Compilation
Related issue(s) (optional)
This is a requirement for this proposal: https://github.com/ballerina-platform/ballerina-library/issues/6378
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response