Open TharmiganK opened 3 weeks ago
In the current Ballerina to OpenAPI specification does not support mapping CORS related configurations in the generated OpenAPI specification.
Example service with CORS configuration:
@http:ServiceConfig { cors: { allowOrigins: ["http://localhost:3000", "http://localhost"], allowCredentials: true, allowHeaders: ["X-Username"], allowMethods: ["GET", "POST"] } } service / on new http:Listener(9090) { ... isolated resource function get winners(@http:Header {name: "X-Username"} string x_username) returns Participant[]|error { ... } @http:ResourceConfig { cors: { allowOrigins: ["http://localhost:3000", "http://localhost"], allowCredentials: true, allowHeaders: ["X-Username", "Content-Type"], allowMethods: ["GET", "POST"] } } isolated resource function post winner(@http:Header {name: "X-Username"} string x_username, Participant payload) returns Participant|error { ... } }
The CORS can be mapped with the relevant HTTP Access Control headers and possibly add the preflight request method(OPTIONS) as well.
Ballerina SwanLake Update 10(2201.10.x)
Current Limitation
In the current Ballerina to OpenAPI specification does not support mapping CORS related configurations in the generated OpenAPI specification.
Example service with CORS configuration:
Suggested Improvement
The CORS can be mapped with the relevant HTTP Access Control headers and possibly add the preflight request method(OPTIONS) as well.
Version
Ballerina SwanLake Update 10(2201.10.x)