OpenAPI Export for API Definition, Swagger UI Binding#1454
OpenAPI Export for API Definition, Swagger UI Binding#1454Nanashi-lab wants to merge 17 commits intogolemcloud:mainfrom
Conversation
golem-worker-service-base/src/gateway_execution/gateway_http_input_executor.rs
Show resolved
Hide resolved
|
PR for CLI Part of the task is here
example of the swagger ui usage in localhost:9900, it rightly shows 9006 (local deployment) as server for testing, it also doesnt show |
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Outdated
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Outdated
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
|
This is a link to repository containing, some wasm-files, api json files and the equivalent yaml output files. |
|
All Checks have passed, that's really good news. |
golem-worker-service-base/tests/api_gateway_end_to_end_tests.rs
Outdated
Show resolved
Hide resolved
|
I matched HEAD with current golem,
|
|
One of my tests failed ERROR test_export_import_api_definition{deps=EnvBasedTestDependencies}: golem_common::tracing: panic panic_info=panicked at integration-tests/tests/api/api_definition.rs:587:10:
called `Result::unwrap()` on an `Err` value: ApiDefinitionError { error: Some(BadRequest(ErrorsBody { errors: ["Invalid JSON"] })) }"I will figure out why this happening. Couldnt replicate this locally. I split the test into one simple test for export endpoint and another for roundtrip test |
|
@jdegoes @vigoo Gentle Reminder - Please review & offer feedback on this PR, which I submitted about a month ago. To ensure it's as easy as possible to review, I've rebased both Could you also let me know the current state of the ticket? Is the PR/Issue still something the team is actively interested in? Knowing this will help me prioritize accordingly. I want to ensure I'm providing everything you need to make a decision on this PR. Please let me know what I can do to help move it forward. To make this process smoother, I'm happy to:
P.S. - The ignored roundtrip should be possible after #1569 |
Yes we definitely want this feature! |
|
@Nanashi-lab I am currently taking a look at this PR |
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
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
|
@Nanashi-lab I would request you to commit the fixes after I finish the review - I will let you know when, otherwise hard for me to review :D It's looking good already, but just need a couple of more hours. |
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
| } | ||
|
|
||
| // Fallback to default object schema if no body is found | ||
| create_default_object_schema() |
There was a problem hiding this comment.
I hope this is not by any accident :)
What is called as default_object_schema? That it expects empty object in the request body?
Couldn't we completely avoid a schema if there is none in the request.body?
| ))), | ||
| ..Default::default() | ||
| }; | ||
| content.insert("application/json".to_string(), media); |
There was a problem hiding this comment.
I don't think it is application/json all the time
There was a problem hiding this comment.
We do support application/text as well, and you can try it out as well.
If our rib script is as follows, and then deploy it by changing the content types
- method: GET
path: /v1/{user}/contents
binding:
type: default
componentName: "amazon:shopping-cart"
response: |
let user: u32 = request.path.user;
let worker = instance("cart-${user}");
{headers: { Content-Type: "application/text" }, body: worker.get-string()}
The worker function merely returns String.
curl -X GET http://localhost:9006/v1/100/contents
this is a string
There was a problem hiding this comment.
And if it's json
{headers: { Content-Type: "application/json" }, body: worker.get-string()}
then,
curl -X GET http://localhost:9006/v1/100/contents
"this is a string"
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_api_definition/http/api_oas_convert.rs
Show resolved
Hide resolved
golem-worker-service-base/src/gateway_execution/swagger_binding_handler.rs
Show resolved
Hide resolved
afsalthaj
left a comment
There was a problem hiding this comment.
I have made some comments. There are a few things to fix before we could merge. I can see you are getting into various internals to reach this point, and pretty sure we can make it all the way if you could fix these comments soon :)
|
@Nanashi-lab Please re-open when 100% of all feedback has been addressed in the way indicated and you are ready for a fresh review. Thank you! |
PR: OpenAPI Export and Swagger UI Support for Golem API Definitions Closes #1178
/claim #1178
This PR provides OpenAPI export functionality and Swagger UI (Binding and CLI) support. Specifically, this PR implements:
/v1/api-definitions/{id}/{version}/exportendpoint to export API Definitions to OpenAPI Specifications.golem-clineeds to be updated with:golem-cli api-definition swaggersubcommand for launching a browser to a generated Swagger UI.golem-cli api-definition exportsubcommand to export an API definition to an OpenAPI schema.System test and verify they interact correctly with the SWAGGER UI (Might not be possible currently all deployment tests fail.)
You can try this out, after building, by creating a new route with
bindingtype swagger-ui, with path without any varriables, example/swagger. If deployed to localhost:9006, you will find your swagger ui there.Your feedback is appreciated! While I work on the remaining task.