From 4bee4cafd03c2477636df8ae91fb4473e5d6e439 Mon Sep 17 00:00:00 2001 From: walterlife Date: Tue, 10 Jan 2023 09:17:35 +0800 Subject: [PATCH] add workflow swagger doc --- .../cmd/controller/docs/docs.go | 392 ++++++++++++++++++ .../cmd/controller/docs/swagger.json | 367 ++++++++++++++++ .../cmd/controller/docs/swagger.yaml | 247 +++++++++++ 3 files changed, 1006 insertions(+) create mode 100644 eventmesh-workflow-go/cmd/controller/docs/docs.go create mode 100644 eventmesh-workflow-go/cmd/controller/docs/swagger.json create mode 100644 eventmesh-workflow-go/cmd/controller/docs/swagger.yaml diff --git a/eventmesh-workflow-go/cmd/controller/docs/docs.go b/eventmesh-workflow-go/cmd/controller/docs/docs.go new file mode 100644 index 0000000000..e27f53ff87 --- /dev/null +++ b/eventmesh-workflow-go/cmd/controller/docs/docs.go @@ -0,0 +1,392 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package docs GENERATED BY SWAG; DO NOT EDIT +// This file was generated by swaggo/swag +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": {}, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/workflow": { + "get": { + "description": "query workflow list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "query workflow list", + "parameters": [ + { + "type": "string", + "description": "workflow id", + "name": "workflow_id", + "in": "query" + }, + { + "type": "string", + "description": "workflow status", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "query page", + "name": "page", + "in": "query" + }, + { + "type": "string", + "description": "query size", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.QueryWorkflowsResponse" + } + }, + "400": { + "description": "Bad Request" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + }, + "post": { + "description": "save a workflow", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "save a workflow", + "parameters": [ + { + "description": "workflow data", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/main.SaveWorkflowRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/workflow/instances": { + "get": { + "description": "query workflow instances", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "query workflow instances", + "parameters": [ + { + "type": "string", + "description": "workflow id", + "name": "workflow_id", + "in": "query" + }, + { + "type": "string", + "description": "query page", + "name": "page", + "in": "query" + }, + { + "type": "string", + "description": "query size", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.QueryWorkflowInstancesResponse" + } + }, + "400": { + "description": "Bad Request" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/workflow/{workflowId}": { + "get": { + "description": "query workflow detail info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "query workflow detail info", + "parameters": [ + { + "type": "string", + "description": "workflow id", + "name": "workflowId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.QueryWorkflowResponse" + } + }, + "400": { + "description": "Bad Request" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + }, + "delete": { + "description": "delete a workflow", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "delete a workflow", + "parameters": [ + { + "type": "string", + "description": "workflow id", + "name": "workflowId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.QueryWorkflowsResponse" + } + }, + "400": { + "description": "Bad Request" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + } + }, + "definitions": { + "main.QueryWorkflowInstancesResponse": { + "type": "object", + "properties": { + "total": { + "description": "total count", + "type": "integer" + }, + "workflow_instances": { + "type": "array", + "items": { + "$ref": "#/definitions/model.WorkflowInstance" + } + } + } + }, + "main.QueryWorkflowResponse": { + "type": "object", + "properties": { + "workflow": { + "$ref": "#/definitions/model.Workflow" + } + } + }, + "main.QueryWorkflowsResponse": { + "type": "object", + "properties": { + "total": { + "description": "total count", + "type": "integer" + }, + "workflows": { + "type": "array", + "items": { + "$ref": "#/definitions/model.Workflow" + } + } + } + }, + "main.SaveWorkflowRequest": { + "type": "object", + "properties": { + "workflow": { + "$ref": "#/definitions/model.Workflow" + } + } + }, + "model.Workflow": { + "type": "object", + "properties": { + "create_time": { + "type": "string" + }, + "definition": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "status": { + "type": "integer" + }, + "total_failed_instances": { + "type": "integer" + }, + "total_instances": { + "type": "integer" + }, + "total_running_instances": { + "type": "integer" + }, + "update_time": { + "type": "string" + }, + "version": { + "type": "string" + }, + "workflow_id": { + "type": "string" + }, + "workflow_name": { + "type": "string" + } + } + }, + "model.WorkflowInstance": { + "type": "object", + "properties": { + "create_time": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "update_time": { + "type": "string" + }, + "workflow_id": { + "type": "string" + }, + "workflow_instance_id": { + "type": "string" + }, + "workflow_status": { + "type": "integer" + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "Workflow API", + Description: "This is a workflow server.", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/eventmesh-workflow-go/cmd/controller/docs/swagger.json b/eventmesh-workflow-go/cmd/controller/docs/swagger.json new file mode 100644 index 0000000000..fe0fd8f321 --- /dev/null +++ b/eventmesh-workflow-go/cmd/controller/docs/swagger.json @@ -0,0 +1,367 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +{ + "swagger": "2.0", + "info": { + "description": "This is a workflow server.", + "title": "Workflow API", + "contact": {}, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "1.0" + }, + "paths": { + "/workflow": { + "get": { + "description": "query workflow list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "query workflow list", + "parameters": [ + { + "type": "string", + "description": "workflow id", + "name": "workflow_id", + "in": "query" + }, + { + "type": "string", + "description": "workflow status", + "name": "status", + "in": "query" + }, + { + "type": "string", + "description": "query page", + "name": "page", + "in": "query" + }, + { + "type": "string", + "description": "query size", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.QueryWorkflowsResponse" + } + }, + "400": { + "description": "Bad Request" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + }, + "post": { + "description": "save a workflow", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "save a workflow", + "parameters": [ + { + "description": "workflow data", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/main.SaveWorkflowRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/workflow/instances": { + "get": { + "description": "query workflow instances", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "query workflow instances", + "parameters": [ + { + "type": "string", + "description": "workflow id", + "name": "workflow_id", + "in": "query" + }, + { + "type": "string", + "description": "query page", + "name": "page", + "in": "query" + }, + { + "type": "string", + "description": "query size", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.QueryWorkflowInstancesResponse" + } + }, + "400": { + "description": "Bad Request" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/workflow/{workflowId}": { + "get": { + "description": "query workflow detail info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "query workflow detail info", + "parameters": [ + { + "type": "string", + "description": "workflow id", + "name": "workflowId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.QueryWorkflowResponse" + } + }, + "400": { + "description": "Bad Request" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + }, + "delete": { + "description": "delete a workflow", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "delete a workflow", + "parameters": [ + { + "type": "string", + "description": "workflow id", + "name": "workflowId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/main.QueryWorkflowsResponse" + } + }, + "400": { + "description": "Bad Request" + }, + "404": { + "description": "Not Found" + }, + "500": { + "description": "Internal Server Error" + } + } + } + } + }, + "definitions": { + "main.QueryWorkflowInstancesResponse": { + "type": "object", + "properties": { + "total": { + "description": "total count", + "type": "integer" + }, + "workflow_instances": { + "type": "array", + "items": { + "$ref": "#/definitions/model.WorkflowInstance" + } + } + } + }, + "main.QueryWorkflowResponse": { + "type": "object", + "properties": { + "workflow": { + "$ref": "#/definitions/model.Workflow" + } + } + }, + "main.QueryWorkflowsResponse": { + "type": "object", + "properties": { + "total": { + "description": "total count", + "type": "integer" + }, + "workflows": { + "type": "array", + "items": { + "$ref": "#/definitions/model.Workflow" + } + } + } + }, + "main.SaveWorkflowRequest": { + "type": "object", + "properties": { + "workflow": { + "$ref": "#/definitions/model.Workflow" + } + } + }, + "model.Workflow": { + "type": "object", + "properties": { + "create_time": { + "type": "string" + }, + "definition": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "status": { + "type": "integer" + }, + "total_failed_instances": { + "type": "integer" + }, + "total_instances": { + "type": "integer" + }, + "total_running_instances": { + "type": "integer" + }, + "update_time": { + "type": "string" + }, + "version": { + "type": "string" + }, + "workflow_id": { + "type": "string" + }, + "workflow_name": { + "type": "string" + } + } + }, + "model.WorkflowInstance": { + "type": "object", + "properties": { + "create_time": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "update_time": { + "type": "string" + }, + "workflow_id": { + "type": "string" + }, + "workflow_instance_id": { + "type": "string" + }, + "workflow_status": { + "type": "integer" + } + } + } + } +} \ No newline at end of file diff --git a/eventmesh-workflow-go/cmd/controller/docs/swagger.yaml b/eventmesh-workflow-go/cmd/controller/docs/swagger.yaml new file mode 100644 index 0000000000..9667a62644 --- /dev/null +++ b/eventmesh-workflow-go/cmd/controller/docs/swagger.yaml @@ -0,0 +1,247 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +definitions: + main.QueryWorkflowInstancesResponse: + properties: + total: + description: total count + type: integer + workflow_instances: + items: + $ref: '#/definitions/model.WorkflowInstance' + type: array + type: object + main.QueryWorkflowResponse: + properties: + workflow: + $ref: '#/definitions/model.Workflow' + type: object + main.QueryWorkflowsResponse: + properties: + total: + description: total count + type: integer + workflows: + items: + $ref: '#/definitions/model.Workflow' + type: array + type: object + main.SaveWorkflowRequest: + properties: + workflow: + $ref: '#/definitions/model.Workflow' + type: object + model.Workflow: + properties: + create_time: + type: string + definition: + type: string + id: + type: integer + status: + type: integer + total_failed_instances: + type: integer + total_instances: + type: integer + total_running_instances: + type: integer + update_time: + type: string + version: + type: string + workflow_id: + type: string + workflow_name: + type: string + type: object + model.WorkflowInstance: + properties: + create_time: + type: string + id: + type: integer + update_time: + type: string + workflow_id: + type: string + workflow_instance_id: + type: string + workflow_status: + type: integer + type: object +info: + contact: {} + description: This is a workflow server. + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + title: Workflow API + version: "1.0" +paths: + /workflow: + get: + consumes: + - application/json + description: query workflow list + parameters: + - description: workflow id + in: query + name: workflow_id + type: string + - description: workflow status + in: query + name: status + type: string + - description: query page + in: query + name: page + type: string + - description: query size + in: query + name: size + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/main.QueryWorkflowsResponse' + "400": + description: Bad Request + "404": + description: Not Found + "500": + description: Internal Server Error + summary: query workflow list + tags: + - workflow + post: + consumes: + - application/json + description: save a workflow + parameters: + - description: workflow data + in: body + name: request + required: true + schema: + $ref: '#/definitions/main.SaveWorkflowRequest' + produces: + - application/json + responses: + "200": + description: OK + "400": + description: Bad Request + "404": + description: Not Found + "500": + description: Internal Server Error + summary: save a workflow + tags: + - workflow + /workflow/{workflowId}: + delete: + consumes: + - application/json + description: delete a workflow + parameters: + - description: workflow id + in: path + name: workflowId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/main.QueryWorkflowsResponse' + "400": + description: Bad Request + "404": + description: Not Found + "500": + description: Internal Server Error + summary: delete a workflow + tags: + - workflow + get: + consumes: + - application/json + description: query workflow detail info + parameters: + - description: workflow id + in: path + name: workflowId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/main.QueryWorkflowResponse' + "400": + description: Bad Request + "404": + description: Not Found + "500": + description: Internal Server Error + summary: query workflow detail info + tags: + - workflow + /workflow/instances: + get: + consumes: + - application/json + description: query workflow instances + parameters: + - description: workflow id + in: query + name: workflow_id + type: string + - description: query page + in: query + name: page + type: string + - description: query size + in: query + name: size + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/main.QueryWorkflowInstancesResponse' + "400": + description: Bad Request + "404": + description: Not Found + "500": + description: Internal Server Error + summary: query workflow instances + tags: + - workflow +swagger: "2.0"