golemcloud / golem

Golem is an open source durable computing platform that makes it easy to build and deploy highly reliable distributed systems.
https://learn.golem.cloud/
Apache License 2.0
530 stars 59 forks source link

Yaml support for API definition #1049

Closed afsalthaj closed 2 weeks ago

afsalthaj commented 2 weeks ago

TODO

OpenAPI in yaml format with multi-line Rib that works

openapi: "3.0.0"
info:
  title: "Sample API"
  version: "1.0.3"
x-golem-api-definition-id: "myapi"
x-golem-api-definition-version: "0.1.1"
paths:
  "/{user-id}/get-cart-contents":
    x-golem-worker-bridge:
      worker-name: "\"foo\""
      component-id: "aae6dd36-8caa-4271-8ef3-cf1f88ef9c97"
      component-version: 0
      response: |
        let style = "font-family: Arial, sans-serif; display: flex; align-items: center; 
                     justify-content: center; height: 100vh; background: linear-gradient(135deg, 
                     #1e3c72, #2a5298); color: #ffffff; text-align: center; padding: 20px;";
        let user: u64 = request.path.user-id;
        {
          Content-Type: "text/html",
          status: 200u64,
          body: "<!DOCTYPE html><html><head></head><body style='${style}'>
                 <div><h1>Welcome to Golem Cloud!</h1>
                 <p style='font-size: 1.5em;'>Hello, User ID: ${user}</p>
                 <p style='color: #dcdcdc;'>Explore your cart contents and more on this personalized page.</p>
                 </div></body></html>"
        }
    get:
      summary: "Get Cart Contents"
      description: "Get the contents of a user's cart"
      parameters:
        - name: "user-id"
          in: "path"
          required: true
          schema:
            type: "string"
      responses:
        "200":
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CartItem"
        "404":
          description: "Contents not found"
components:
  schemas:
    CartItem:
      type: "object"
      properties:
        id:
          type: "string"
        name:
          type: "string"
        price:
          type: "number"
afsalthaj commented 2 weeks ago

Part of ##1035