fix & improve example

This commit is contained in:
timurgordon
2025-02-12 03:36:26 +03:00
parent 80254739b0
commit 13471d4ca5
5 changed files with 29 additions and 30 deletions

View File

@@ -0,0 +1,2 @@
merchant
merchant_actor

Binary file not shown.

View File

@@ -11,18 +11,16 @@ const openapi_spec_path = os.join_path(example_dir, 'openapi.json')
// the actor specification obtained from the OpenRPC Specification
openapi_spec := openapi.new(path: openapi_spec_path)!
openapi_spec := openapi.new(path: openapi_spec_path, process: true)!
actor_spec := specification.from_openapi(openapi_spec)!
println(actor_spec)
actor_module := generator.generate_actor_module(
actor_module := generator.generate_actor_folder(
actor_spec,
interfaces: [.openapi, .http]
)!
actor_module.write(example_dir,
format: false
format: true
overwrite: true
compile: false
)!

View File

@@ -1,19 +1,20 @@
{
"openapi": "3.0.1",
"info": {
"title": "Commerce API",
"title": "Merchant",
"description": "API for e-commerce operations including merchants, products, and orders",
"version": "1.0.0"
},
"servers": [
{
"url": "http://localhost:8080",
"description": "Local development server"
}
],
"servers": [{
"url": "http://localhost:8080",
"description": "Local development server"
},{
"url": "http://localhost:8080/openapi/example",
"description": "Local example server"
}],
"components": {
"schemas": {
"Merchant": {
"Store": {
"type": "object",
"properties": {
"id": {
@@ -326,7 +327,7 @@
"paths": {
"/merchants": {
"post": {
"summary": "Create a new merchant",
"summary": "Create a new store",
"operationId": "createMerchant",
"requestBody": {
"required": true,
@@ -368,11 +369,11 @@
},
"responses": {
"201": {
"description": "Merchant created successfully",
"description": "Store created successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Merchant"
"$ref": "#/components/schemas/Store"
},
"example": {
"id": "123e4567-e89b-12d3-a456-426614174000",
@@ -393,7 +394,7 @@
},
"example": {
"code": 400,
"message": "Invalid merchant data provided"
"message": "Invalid store data provided"
}
}
}
@@ -584,7 +585,7 @@
}
},
"404": {
"description": "Merchant not found",
"description": "Store not found",
"content": {
"application/json": {
"schema": {
@@ -592,7 +593,7 @@
},
"example": {
"code": 404,
"message": "Merchant not found"
"message": "Store not found"
}
}
}
@@ -666,7 +667,7 @@
}
},
"404": {
"description": "Template or merchant not found",
"description": "Template or store not found",
"content": {
"application/json": {
"schema": {
@@ -868,7 +869,7 @@
},
"/merchants/{merchantId}/products": {
"get": {
"summary": "Get all products for a merchant",
"summary": "Get all products for a store",
"operationId": "getMerchantProducts",
"parameters": [
{
@@ -884,7 +885,7 @@
],
"responses": {
"200": {
"description": "List of merchant's products",
"description": "List of store's products",
"content": {
"application/json": {
"schema": {
@@ -910,7 +911,7 @@
}
},
"404": {
"description": "Merchant not found",
"description": "Store not found",
"content": {
"application/json": {
"schema": {
@@ -918,7 +919,7 @@
},
"example": {
"code": 404,
"message": "Merchant not found"
"message": "Store not found"
}
}
}
@@ -928,7 +929,7 @@
},
"/merchants/{merchantId}/orders": {
"get": {
"summary": "Get all orders for a merchant's products",
"summary": "Get all orders for a store's products",
"operationId": "getMerchantOrders",
"parameters": [
{
@@ -944,7 +945,7 @@
],
"responses": {
"200": {
"description": "List of orders containing merchant's products",
"description": "List of orders containing store's products",
"content": {
"application/json": {
"schema": {
@@ -976,7 +977,7 @@
}
},
"404": {
"description": "Merchant not found",
"description": "Store not found",
"content": {
"application/json": {
"schema": {
@@ -984,7 +985,7 @@
},
"example": {
"code": 404,
"message": "Merchant not found"
"message": "Store not found"
}
}
}

View File

@@ -5,11 +5,9 @@ import freeflowuniverse.herolib.baobab.specification
import freeflowuniverse.herolib.schemas.openapi
import os
const example_dir = os.dir(@FILE)
const openapi_spec_path = os.join_path(example_dir, 'openapi.json')
// the actor specification obtained from the OpenRPC Specification
openapi_spec := openapi.new(path: openapi_spec_path)!
actor_spec := specification.from_openapi(openapi_spec)!