-
Notifications
You must be signed in to change notification settings - Fork 126
OpenApi Export and Swagger UI Binding #1671
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
base: main
Are you sure you want to change the base?
Conversation
The Changes Requested Done
Minor Unresolved
Major Unresolved
|
@afsalthaj this is the explanation. I have addressed almost all comments from old PR, with the major exception of content-type in response. Content-Type and StatusRibOutputTypeInfo only contains the AnalysedType, and not the actual value of status and header (Content-Type). The exact values are calculated at runtime. Both are valid, working rib-script. In first we can set status at runtime, and in second we can set content-type during runtime. let input = request.body.input;
let worker = instance("worker");
let result = worker.echo("Test");
{status: input: u64, body: result} let input: string = request.body.input;
let worker = instance("worker-static");
let result = worker.echo("Test", 3);
{headers: {Content-Type: input, userid: "foo"}, status: 200: u64, body: result} For the Status Case -I determine the status by using method (POST -> 201, GET-> 200, and so on) and for all other cases (Where rib may output multiple types /v0.0.1/test1:
post:
responses:
default:
description: Created
content:
application/json:
schema:
type: string
'201':
description: Created
content:
application/json:
schema:
type: string For the Content-Type Case -Current Golem-Rib behavior for String and other Primitive types, if you try application/text or application/octet-stream or any valid name. It will try to output it in that form, including image/png. For application/json which is the default, it outputs json. If the AnalysedType is Complex, for all other content-type it will output a messaging "So and so analaysed-type could not be translated to content-type". for application/json it will output the json In the first-case currently in api-oas-convert we pass application-json, if swagger ui receives application-text it handles it gracefully. |
Thanks @Nanashi-lab for raising the PR again
Could you please explain this in detail? All information should still be available in the rib output type info. Also I hope this PR addresses the concerns raised I in this PR. #1454 |
More thoughts on RibOutputTypeInfo on figuring exact values of status and content-type {headers: {Content-Type: \"application/text\", userid: \"foo\"}, status: 200: u64, body: \"Success\"} RibOutputTypeInfo "analysedType": {
"fields": [
{
"name": "headers",
"typ": {
"fields": [
{
"name": "Content-Type",
"typ": {
"type": "Str"
}
},
{
"name": "userid",
"typ": {
"type": "Str"
}
}
],
"type": "Record"
}
},
{
"name": "status",
"typ": {
"type": "U64"
}
},
{
"name": "body",
"typ": {
"type": "Str"
}
}
],
"type": "Record"
} This is the RibOutputTypeInfo Structure, the actual values for status, body and header are in the rib-expression and the exact value is calculated when the api is called. RibOutputTypeInfo contains NameTypePair and not ValueAndType We cannot extract content-type, status etc from rib-expression, because it can be set by the user at runtime, also string scanning might lead to false information from comments example |
Another way to handle this would be, since application/text or application/xml both only handle primitive types like string If the body is primitive, we can add all possible outcome I am going to move forward with the solution @jdegoes & @afsalthaj if you have any comments on status and content-type issue, and how I am handling it, please tell me. (Look at comment above for more information) responses:
'200':
description: Success
content:
application/json:
type: string
application/xml:
type: string
text/plain:
type: string
application/text:
type: string |
Add /v1/api-definition/:id/:version/export endpoint to export API definition as OAS Add Swagger UI binding for API definition Add Swagger UI executor for Swagger UI binding
Add tests for CORS and security
Add end-to-end test for Swagger UI
Add Export to test framework Add Integration test for full round trip export Fix Loopup API error in gateway_http_input_executor
Clean testframework, and swagger-ui handler Remove string scanning in api_oas_convert.rs Change add new more comprehensive test in api_oas_convert_tests Cargo fix
Test for default response
Remove extract_path_parameters Add support for query parameters Add test for first class workers Add test for query parameters and variant Cargo make fix
Add Getters for Component Name and Version Change ExportApiDefinition to ExportOpenapiSpec
Add Flag and Chr Improve Response Code Add Full Test Suite Cargo Make Fix
Add OpenApi to Swagger UI Binding Add Async to OpenAPI Conversion Fix Cors Response Extract Pass Conversion Context to OpenAPI Conversion
Response content-type application/json
git ignore openapi in golem-client and golem-cloud-client Fix swagger binding handler license Improve api_oas_convert.rs
Fix roundtrip test
* 1.2.2 RC1 * Following oss changes
@afsalthaj Perhaps Rib can return "singleton types" when possible. It's not likely the content type or status code is a variable: it's likely it's a literal, embedded into the Rib script. If Rib had any kind of support for singleton types, e.g. |
Content-Type will be mostly literal. Status can have a few possible Literal values, for result and variant. In OpenAPI v3, responses:
'200':
description: Success
content:
application/json:
type: string
'*/*':
type: string This works also for complex types, because for complex type in application/text or others, output string error |
Most of the code is done. Once the merge between cloud and oss happens, I will rebase, and fix any leftover issues. |
/closes #1178
/claim #1178
Docs is still left to do. Golem-Cli needs to be updated to latest.
CI api-and-integration-tests, API Test keeps timing out after 45 mins, I will figure and fix this.
I am ready for a review @afsalthaj I have added the explanation comment on content-type and status. Do tell if I have that right ? and if so is the current way of handling it is robust ?
Link to Videos and Files -
Video One - Link
This covers the Export Endpoint, and the Export CLI Command, and Round-Trip Test
Video Two - Link
This covers the Swagger CLI Command, and Swagger UI Binding
If you want to check the actual conversion between AnalysedType and OpenApi Spec, you can either