Skip to content

Commit

Permalink
add swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouop0 committed Jan 8, 2025
1 parent b733c67 commit d4139ed
Show file tree
Hide file tree
Showing 8 changed files with 617 additions and 66 deletions.
181 changes: 181 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs

import "github.com/swaggo/swag"

const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/blocks": {
"get": {
"description": "Get a paginated list of sync blocks",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Blocks"
],
"summary": "Get sync blocks with pagination",
"parameters": [
{
"type": "integer",
"description": "Page number (default: 1)",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "Page size (default: 10, max: 100)",
"name": "pageSize",
"in": "query"
}
],
"responses": {
"200": {
"description": "code\": 200, \"msg\": \"success\", \"data\": {\"list\": []schema.SyncBlock, \"total\": int64, \"page\": int, \"pageSize\": int}",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/blocks/relayedMessage/{hash}": {
"get": {
"description": "Get relayed message details using message hash",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Messages"
],
"summary": "Get relayed message by hash",
"parameters": [
{
"type": "string",
"description": "Message Hash",
"name": "hash",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "code\": 200, \"msg\": \"success\", \"data\": schema.SyncEvent",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/blocks/sentMessage/{hash}": {
"get": {
"description": "Get sent message details using message hash",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Messages"
],
"summary": "Get sent message by hash",
"parameters": [
{
"type": "string",
"description": "Message Hash",
"name": "hash",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "code\": 200, \"msg\": \"success\", \"data\": schema.SyncEvent",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/blocks/{blockNumber}/executingMessage": {
"get": {
"description": "Get all executing messages for a specific block number",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Messages"
],
"summary": "Get executing messages by block number",
"parameters": [
{
"type": "integer",
"description": "Block Number",
"name": "blockNumber",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "code\": 200, \"msg\": \"success\", \"data\": []schema.SyncEvent",
"schema": {
"type": "object",
"additionalProperties": true
}
},
"400": {
"description": "code\": 400, \"msg\": \"Invalid block number\", \"data\": nil",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
}
}
}`

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "localhost:8080",
BasePath: "/",
Schemes: []string{},
Title: "Interop Backend API",
Description: "Interop Backend Service API Documentation",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
157 changes: 157 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{
"swagger": "2.0",
"info": {
"description": "Interop Backend Service API Documentation",
"title": "Interop Backend API",
"contact": {},
"version": "1.0"
},
"host": "localhost:8080",
"basePath": "/",
"paths": {
"/blocks": {
"get": {
"description": "Get a paginated list of sync blocks",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Blocks"
],
"summary": "Get sync blocks with pagination",
"parameters": [
{
"type": "integer",
"description": "Page number (default: 1)",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "Page size (default: 10, max: 100)",
"name": "pageSize",
"in": "query"
}
],
"responses": {
"200": {
"description": "code\": 200, \"msg\": \"success\", \"data\": {\"list\": []schema.SyncBlock, \"total\": int64, \"page\": int, \"pageSize\": int}",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/blocks/relayedMessage/{hash}": {
"get": {
"description": "Get relayed message details using message hash",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Messages"
],
"summary": "Get relayed message by hash",
"parameters": [
{
"type": "string",
"description": "Message Hash",
"name": "hash",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "code\": 200, \"msg\": \"success\", \"data\": schema.SyncEvent",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/blocks/sentMessage/{hash}": {
"get": {
"description": "Get sent message details using message hash",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Messages"
],
"summary": "Get sent message by hash",
"parameters": [
{
"type": "string",
"description": "Message Hash",
"name": "hash",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "code\": 200, \"msg\": \"success\", \"data\": schema.SyncEvent",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/blocks/{blockNumber}/executingMessage": {
"get": {
"description": "Get all executing messages for a specific block number",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Messages"
],
"summary": "Get executing messages by block number",
"parameters": [
{
"type": "integer",
"description": "Block Number",
"name": "blockNumber",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "code\": 200, \"msg\": \"success\", \"data\": []schema.SyncEvent",
"schema": {
"type": "object",
"additionalProperties": true
}
},
"400": {
"description": "code\": 400, \"msg\": \"Invalid block number\", \"data\": nil",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
}
}
}
Loading

0 comments on commit d4139ed

Please sign in to comment.