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:

  • Key Features:
    • OpenAPI Export Endpoint: Added /v1/api-definitions/{id}/{version}/export endpoint to export API Definitions to OpenAPI Specifications.
    • Full and Lossless Conversion: Implemented conversion logic for request and response types, accurate mapping of type to OpenAPI schema.
    • Swagger UI Binding Type: A new “Swagger UI” binding type for routes in the Worker Gateway, allowing for serving of Swagger UI interfaces from API definitions when deployed.
    • Swagger UI Integration: Code to render the exported OpenAPI schema as a Swagger UI for user-friendly API testing.
    • Testing: Added basic unit for API to OpenAPI spec, tests include, verifying CORS, secuirty, parameter, input and output maping, I have also added end-to-end tests to validate Swagger UI.
    • Golem CLI Updates: golem-cli needs to be updated with:
      • golem-cli api-definition swagger subcommand for launching a browser to a generated Swagger UI.
      • golem-cli api-definition export subcommand to export an API definition to an OpenAPI schema.
    • Documentation: Documentation is required to explain these new features and will be provided in a separate PR to the docs repository.
    • System/Integration Tests:
      • System tests to OpenAPI Spec from API, and attempting full circle by importing the 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.

Capture Capture2

Claim

Total prize pool $10,000
Total paid $0
Status Pending
Submitted April 10, 2025
Last updated April 10, 2025

Contributors

AJ

Ajay RV

@Nanashi-lab

100%

Sponsors

GO

Golem Cloud

@golemcloud

$10,000