diff --git a/src/api/pc_api.go b/src/api/pc_api.go index a42e815..a5bfb0e 100644 --- a/src/api/pc_api.go +++ b/src/api/pc_api.go @@ -9,17 +9,20 @@ import ( "github.com/gin-gonic/gin" ) -// @title Swagger Process Compose API -// @version 1.0 -// @description This is a sample server Process Compose server. +// @title Process Compose API +// @version 1.0 +// @description This is a sample Process Compose server. -// @contact.name Process Compose Discord Channel -// @contact.url https://discord.gg/S4xgmRSHdC +// @contact.name Process Compose Discord Channel +// @contact.url https://discord.gg/S4xgmRSHdC -// @license.name Apache 2.0 -// @license.url http://www.apache.org/licenses/LICENSE-2.0.html +// @license.name Apache 2.0 +// @license.url http://www.apache.org/licenses/LICENSE-2.0.html -// @externalDocs.url https://f1bonacc1.github.io/process-compose/ +// @externalDocs.url https://f1bonacc1.github.io/process-compose/ +// @host localhost:8080 +// @BasePath / +// @query.collection.format multi type PcApi struct { project app.IProject @@ -30,14 +33,15 @@ func NewPcApi(project app.IProject) *PcApi { } // @Schemes -// @Description Retrieves the given process and its status -// @Tags Process -// @Summary Get process state -// @Produce json -// @Param name path string true "Process Name" -// @Success 200 {object} types.ProcessState -// @Failure 400 {object} map[string]string -// @Router /process/{name} [get] +// @Id GetProcess +// @Description Retrieves the given process and its status +// @Tags Process +// @Summary Get process state +// @Produce json +// @Param name path string true "Process Name" +// @Success 200 {object} types.ProcessState +// @Failure 400 {object} map[string]string +// @Router /process/{name} [get] func (api *PcApi) GetProcess(c *gin.Context) { name := c.Param("name") @@ -51,14 +55,15 @@ func (api *PcApi) GetProcess(c *gin.Context) { } // @Schemes -// @Description Retrieves the given process and its config -// @Tags Process -// @Summary Get process config -// @Produce json -// @Param name path string true "Process Name" -// @Success 200 {object} types.ProcessConfig -// @Failure 400 {object} map[string]string -// @Router /process/info/{name} [get] +// @Id GetProcessInfo +// @Description Retrieves the given process and its config +// @Tags Process +// @Summary Get process config +// @Produce json +// @Param name path string true "Process Name" +// @Success 200 {object} types.ProcessConfig +// @Failure 400 {object} map[string]string +// @Router /process/info/{name} [get] func (api *PcApi) GetProcessInfo(c *gin.Context) { name := c.Param("name") @@ -72,13 +77,14 @@ func (api *PcApi) GetProcessInfo(c *gin.Context) { } // @Schemes -// @Description Retrieves all the configured processes and their status -// @Tags Process -// @Summary Get all processes -// @Produce json -// @Success 200 {object} types.ProcessesState "Processes Status" -// @Failure 400 {object} map[string]string -// @Router /processes [get] +// @Id GetProcesses +// @Description Retrieves all the configured processes and their status +// @Tags Process +// @Summary Get all processes +// @Produce json +// @Success 200 {object} types.ProcessesState "Processes Status" +// @Failure 400 {object} map[string]string +// @Router /processes [get] func (api *PcApi) GetProcesses(c *gin.Context) { states, err := api.project.GetProcessesState() if err != nil { @@ -90,16 +96,17 @@ func (api *PcApi) GetProcesses(c *gin.Context) { } // @Schemes -// @Description Retrieves the process logs -// @Tags Process -// @Summary Get process logs -// @Produce json -// @Param name path string true "Process Name" -// @Param endOffset path int true "Offset from the end of the log" -// @Param limit path int true "Limit of lines to get (0 will get all the lines till the end)" -// @Success 200 {object} map[string][]string "Process Logs" -// @Failure 400 {object} map[string]string -// @Router /process/logs/{name}/{endOffset}/{limit} [get] +// @Id GetProcessLogs +// @Description Retrieves the process logs +// @Tags Process +// @Summary Get process logs +// @Produce json +// @Param name path string true "Process Name" +// @Param endOffset path int true "Offset from the end of the log" +// @Param limit path int true "Limit of lines to get (0 will get all the lines till the end)" +// @Success 200 {object} map[string][]string "Process Logs" +// @Failure 400 {object} map[string]string +// @Router /process/logs/{name}/{endOffset}/{limit} [get] func (api *PcApi) GetProcessLogs(c *gin.Context) { name := c.Param("name") endOffset, err := strconv.Atoi(c.Param("endOffset")) @@ -124,14 +131,15 @@ func (api *PcApi) GetProcessLogs(c *gin.Context) { } // @Schemes -// @Description Sends kill signal to the process -// @Tags Process -// @Summary Stop a process -// @Produce json -// @Param name path string true "Process Name" -// @Success 200 {object} map[string]string "Stopped Process Name" -// @Failure 400 {object} map[string]string -// @Router /process/stop/{name} [patch] +// @Id StopProcess +// @Description Sends kill signal to the process +// @Tags Process +// @Summary Stop a process +// @Produce json +// @Param name path string true "Process Name" +// @Success 200 {object} map[string]string "Stopped Process Name" +// @Failure 400 {object} map[string]string +// @Router /process/stop/{name} [patch] func (api *PcApi) StopProcess(c *gin.Context) { name := c.Param("name") err := api.project.StopProcess(name) @@ -144,15 +152,19 @@ func (api *PcApi) StopProcess(c *gin.Context) { } // @Schemes -// @Description Sends kill signal to the processes list -// @Tags Process -// @Summary Stop processes -// @Produce json -// @Param []string body []string true "Processes Names" -// @Success 200 {object} map[string]string "Stopped Processes Names" -// @Success 207 {object} map[string]string "Stopped Processes Names" -// @Failure 400 {object} map[string]string -// @Router /processes/stop [patch] +// @Id StopProcesses +// @Description Sends kill signal to the processes list +// @Tags Process +// @Summary Stop processes +// @Accept json +// +// @Param []string body []string true "Processes Names" +// +// @Produce json +// @Success 200 {object} map[string]string "Stopped Processes Names" +// @Success 207 {object} map[string]string "Stopped Processes Names" +// @Failure 400 {object} map[string]string +// @Router /processes/stop [patch] func (api *PcApi) StopProcesses(c *gin.Context) { var names []string if err := c.ShouldBindJSON(&names); err != nil { @@ -173,14 +185,15 @@ func (api *PcApi) StopProcesses(c *gin.Context) { } // @Schemes -// @Description Starts the process if the state is not 'running' or 'pending' -// @Tags Process -// @Summary Start a process -// @Produce json -// @Param name path string true "Process Name" -// @Success 200 {object} map[string]string "Started Process Name" -// @Failure 400 {object} map[string]string -// @Router /process/start/{name} [post] +// @Id StartProcess +// @Description Starts the process if the state is not 'running' or 'pending' +// @Tags Process +// @Summary Start a process +// @Produce json +// @Param name path string true "Process Name" +// @Success 200 {object} map[string]string "Started Process Name" +// @Failure 400 {object} map[string]string +// @Router /process/start/{name} [post] func (api *PcApi) StartProcess(c *gin.Context) { name := c.Param("name") err := api.project.StartProcess(name) @@ -193,14 +206,15 @@ func (api *PcApi) StartProcess(c *gin.Context) { } // @Schemes -// @Description Restarts the process -// @Tags Process -// @Summary Restart a process -// @Produce json -// @Param name path string true "Process Name" -// @Success 200 {object} map[string]string "Restarted Process Name" -// @Failure 400 {object} map[string]string -// @Router /process/restart/{name} [post] +// @Id RestartProcess +// @Description Restarts the process +// @Tags Process +// @Summary Restart a process +// @Produce json +// @Param name path string true "Process Name" +// @Success 200 {object} map[string]string "Restarted Process Name" +// @Failure 400 {object} map[string]string +// @Router /process/restart/{name} [post] func (api *PcApi) RestartProcess(c *gin.Context) { name := c.Param("name") err := api.project.RestartProcess(name) @@ -213,15 +227,16 @@ func (api *PcApi) RestartProcess(c *gin.Context) { } // @Schemes -// @Description Scale a process -// @Tags Process -// @Summary Scale a process to a given replicas count -// @Produce json -// @Param name path string true "Process Name" -// @Param scale path int true "New amount of process replicas" -// @Success 200 {object} map[string]string "Scaled Process Name" -// @Failure 400 {object} map[string]string -// @Router /process/scale/{name}/{scale} [patch] +// @Id ScaleProcess +// @Description Scale a process +// @Tags Process +// @Summary Scale a process to a given replicas count +// @Produce json +// @Param name path string true "Process Name" +// @Param scale path int true "New amount of process replicas" +// @Success 200 {object} map[string]string "Scaled Process Name" +// @Failure 400 {object} map[string]string +// @Router /process/scale/{name}/{scale} [patch] func (api *PcApi) ScaleProcess(c *gin.Context) { name := c.Param("name") scale, err := strconv.Atoi(c.Param("scale")) @@ -239,24 +254,26 @@ func (api *PcApi) ScaleProcess(c *gin.Context) { } // @Schemes -// @Description Check if server is responding -// @Tags Liveness -// @Summary Liveness Check -// @Produce json -// @Success 200 -// @Router /live [get] +// @Id IsAlive +// @Description Check if server is responding +// @Tags Liveness +// @Summary Liveness Check +// @Produce json +// @Success 200 +// @Router /live [get] func (api *PcApi) IsAlive(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"status": "alive"}) } // @Schemes -// @Description Get process compose hostname -// @Tags Hostname -// @Summary Get Hostname -// @Produce json -// @Success 200 {object} map[string]string "Hostname" -// @Failure 400 {object} map[string]string -// @Router /hostname [get] +// @Id GetHostName +// @Description Get process compose hostname +// @Tags Hostname +// @Summary Get Hostname +// @Produce json +// @Success 200 {object} map[string]string "Hostname" +// @Failure 400 {object} map[string]string +// @Router /hostname [get] func (api *PcApi) GetHostName(c *gin.Context) { name, err := api.project.GetHostName() if err != nil { @@ -268,14 +285,15 @@ func (api *PcApi) GetHostName(c *gin.Context) { } // @Schemes -// @Description Retrieves process open ports -// @Tags Process -// @Summary Get process ports -// @Produce json -// @Param name path string true "Process Name" -// @Success 200 {object} types.ProcessPorts "Process Ports" -// @Failure 400 {object} map[string]string -// @Router /process/ports/{name} [get] +// @Id GetProcessPorts +// @Description Retrieves process open ports +// @Tags Process +// @Summary Get process ports +// @Produce json +// @Param name path string true "Process Name" +// @Success 200 {object} types.ProcessPorts "Process Ports" +// @Failure 400 {object} map[string]string +// @Router /process/ports/{name} [get] func (api *PcApi) GetProcessPorts(c *gin.Context) { name := c.Param("name") @@ -289,26 +307,28 @@ func (api *PcApi) GetProcessPorts(c *gin.Context) { } // @Schemes -// @Description Shuts down the server -// @Tags Project -// @Summary Stops all the processes and the server -// @Produce json -// @Success 200 {object} map[string]string "Stopped Server" -// @Router /project/stop [post] +// @Id ShutDownProject +// @Description Shuts down the server +// @Tags Project +// @Summary Stops all the processes and the server +// @Produce json +// @Success 200 {object} map[string]string "Stopped Server" +// @Router /project/stop [post] func (api *PcApi) ShutDownProject(c *gin.Context) { api.project.ShutDownProject() c.JSON(http.StatusOK, gin.H{"status": "stopped"}) } // @Schemes -// @Description Update running project -// @Tags Project -// @Summary Updates running processes -// @Produce json -// @Success 200 {object} map[string]string "Update Project Status" -// @Success 207 {object} map[string]string "Update Project Status" -// @Failure 400 {object} map[string]string -// @Router /project [post] +// @Id UpdateProject +// @Description Update running project +// @Tags Project +// @Summary Updates running processes +// @Produce json +// @Success 200 {object} map[string]string "Update Project Status" +// @Success 207 {object} map[string]string "Update Project Status" +// @Failure 400 {object} map[string]string +// @Router /project [post] func (api *PcApi) UpdateProject(c *gin.Context) { var project types.Project if err := c.ShouldBindJSON(&project); err != nil { @@ -328,13 +348,14 @@ func (api *PcApi) UpdateProject(c *gin.Context) { } // @Schemes -// @Description Update porcess -// @Tags Process -// @Summary Updates process configuration -// @Produce json -// @Success 200 {object} types.ProcessConfig "Updated Process Config" -// @Failure 400 {object} map[string]string -// @Router /process [post] +// @Id UpdateProcess +// @Description Update porcess +// @Tags Process +// @Summary Updates process configuration +// @Produce json +// @Success 200 {object} types.ProcessConfig "Updated Process Config" +// @Failure 400 {object} map[string]string +// @Router /process [post] func (api *PcApi) UpdateProcess(c *gin.Context) { var proc types.ProcessConfig if err := c.ShouldBindJSON(&proc); err != nil { @@ -350,13 +371,14 @@ func (api *PcApi) UpdateProcess(c *gin.Context) { } // @Schemes -// @Description Retrieves project state information -// @Tags Project -// @Summary Get project state -// @Produce json -// @Success 200 {object} types.ProjectState "Project State" -// @Failure 500 {object} map[string]string -// @Router /project/state [get] +// @Id GetProjectState +// @Description Retrieves project state information +// @Tags Project +// @Summary Get project state +// @Produce json +// @Success 200 {object} types.ProjectState "Project State" +// @Failure 500 {object} map[string]string +// @Router /project/state [get] func (api *PcApi) GetProjectState(c *gin.Context) { withMemory := c.DefaultQuery("withMemory", "false") checkMem, _ := strconv.ParseBool(withMemory) @@ -371,14 +393,15 @@ func (api *PcApi) GetProjectState(c *gin.Context) { } // @Schemes -// @Description Reload project state from config -// @Tags Project -// @Summary Reload project -// @Produce json -// @Success 200 {object} map[string]string "Update Project Status" -// @Success 207 {object} map[string]string "Update Project Status" -// @Failure 400 {object} map[string]string -// @Router /project/configuration [post] +// @Id ReloadProject +// @Description Reload project state from config +// @Tags Project +// @Summary Reload project +// @Produce json +// @Success 200 {object} map[string]string "Update Project Status" +// @Success 207 {object} map[string]string "Update Project Status" +// @Failure 400 {object} map[string]string +// @Router /project/configuration [post] func (api *PcApi) ReloadProject(c *gin.Context) { status, err := api.project.ReloadProject() if err != nil { diff --git a/src/api/routes.go b/src/api/routes.go index 0dc9157..7a47176 100644 --- a/src/api/routes.go +++ b/src/api/routes.go @@ -9,21 +9,6 @@ import ( "net/url" ) -// @title Process Compose API -// @version 1.0 -// @description process compose description - -// @contact.name API Support -// @contact.url http://www.swagger.io/support -// @contact.email support@swagger.io - -// @license.name Appache 2.0 -// @license.url https://opensource.org/licenses/MIT - -// @host localhost:8080 -// @BasePath / -// @query.collection.format multi - // InitRoutes initialize routing information func InitRoutes(useLogger bool, handler *PcApi) *gin.Engine { r := gin.New() diff --git a/src/docs/docs.go b/src/docs/docs.go index 0e7f78e..cd1f8f4 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -32,6 +32,7 @@ const docTemplate = `{ "Hostname" ], "summary": "Get Hostname", + "operationId": "GetHostName", "responses": { "200": { "description": "Hostname", @@ -64,6 +65,7 @@ const docTemplate = `{ "Liveness" ], "summary": "Liveness Check", + "operationId": "IsAlive", "responses": { "200": { "description": "OK" @@ -81,6 +83,7 @@ const docTemplate = `{ "Process" ], "summary": "Updates process configuration", + "operationId": "UpdateProcess", "responses": { "200": { "description": "Updated Process Config", @@ -110,6 +113,7 @@ const docTemplate = `{ "Process" ], "summary": "Get process config", + "operationId": "GetProcessInfo", "parameters": [ { "type": "string", @@ -148,6 +152,7 @@ const docTemplate = `{ "Process" ], "summary": "Get process logs", + "operationId": "GetProcessLogs", "parameters": [ { "type": "string", @@ -206,6 +211,7 @@ const docTemplate = `{ "Process" ], "summary": "Get process ports", + "operationId": "GetProcessPorts", "parameters": [ { "type": "string", @@ -244,6 +250,7 @@ const docTemplate = `{ "Process" ], "summary": "Restart a process", + "operationId": "RestartProcess", "parameters": [ { "type": "string", @@ -285,6 +292,7 @@ const docTemplate = `{ "Process" ], "summary": "Scale a process to a given replicas count", + "operationId": "ScaleProcess", "parameters": [ { "type": "string", @@ -333,6 +341,7 @@ const docTemplate = `{ "Process" ], "summary": "Start a process", + "operationId": "StartProcess", "parameters": [ { "type": "string", @@ -374,6 +383,7 @@ const docTemplate = `{ "Process" ], "summary": "Stop a process", + "operationId": "StopProcess", "parameters": [ { "type": "string", @@ -415,6 +425,7 @@ const docTemplate = `{ "Process" ], "summary": "Get process state", + "operationId": "GetProcess", "parameters": [ { "type": "string", @@ -453,6 +464,7 @@ const docTemplate = `{ "Process" ], "summary": "Get all processes", + "operationId": "GetProcesses", "responses": { "200": { "description": "Processes Status", @@ -475,6 +487,9 @@ const docTemplate = `{ "/processes/stop": { "patch": { "description": "Sends kill signal to the processes list", + "consumes": [ + "application/json" + ], "produces": [ "application/json" ], @@ -482,6 +497,7 @@ const docTemplate = `{ "Process" ], "summary": "Stop processes", + "operationId": "StopProcesses", "parameters": [ { "description": "Processes Names", @@ -537,6 +553,7 @@ const docTemplate = `{ "Project" ], "summary": "Updates running processes", + "operationId": "UpdateProject", "responses": { "200": { "description": "Update Project Status", @@ -578,6 +595,7 @@ const docTemplate = `{ "Project" ], "summary": "Reload project", + "operationId": "ReloadProject", "responses": { "200": { "description": "Update Project Status", @@ -619,6 +637,7 @@ const docTemplate = `{ "Project" ], "summary": "Get project state", + "operationId": "GetProjectState", "responses": { "200": { "description": "Project State", @@ -648,6 +667,7 @@ const docTemplate = `{ "Project" ], "summary": "Stops all the processes and the server", + "operationId": "ShutDownProject", "responses": { "200": { "description": "Stopped Server", @@ -720,29 +740,6 @@ const docTemplate = `{ } } }, - "time.Duration": { - "type": "integer", - "enum": [ - -9223372036854775808, - 9223372036854775807, - 1, - 1000, - 1000000, - 1000000000, - 60000000000, - 3600000000000 - ], - "x-enum-varnames": [ - "minDuration", - "maxDuration", - "Nanosecond", - "Microsecond", - "Millisecond", - "Second", - "Minute", - "Hour" - ] - }, "types.DependsOnConfig": { "type": "object", "additionalProperties": { @@ -974,7 +971,7 @@ const docTemplate = `{ "type": "object", "properties": { "age": { - "$ref": "#/definitions/time.Duration" + "type": "integer" }, "exit_code": { "type": "integer" @@ -1050,7 +1047,7 @@ const docTemplate = `{ "type": "string" }, "upTime": { - "$ref": "#/definitions/time.Duration" + "type": "integer" }, "userName": { "type": "string" @@ -1110,11 +1107,11 @@ const docTemplate = `{ // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ Version: "1.0", - Host: "", - BasePath: "", + Host: "localhost:8080", + BasePath: "/", Schemes: []string{}, - Title: "Swagger Process Compose API", - Description: "This is a sample server Process Compose server.", + Title: "Process Compose API", + Description: "This is a sample Process Compose server.", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, LeftDelim: "{{", diff --git a/src/docs/swagger.json b/src/docs/swagger.json index 8fc5246..0e445c6 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -58,29 +58,6 @@ }, "type": "object" }, - "time.Duration": { - "enum": [ - -9223372036854776000, - 9223372036854776000, - 1, - 1000, - 1000000, - 1000000000, - 60000000000, - 3600000000000 - ], - "type": "integer", - "x-enum-varnames": [ - "minDuration", - "maxDuration", - "Nanosecond", - "Microsecond", - "Millisecond", - "Second", - "Minute", - "Hour" - ] - }, "types.DependsOnConfig": { "additionalProperties": { "$ref": "#/components/schemas/types.ProcessDependency" @@ -311,7 +288,7 @@ "types.ProcessState": { "properties": { "age": { - "$ref": "#/components/schemas/time.Duration" + "type": "integer" }, "exit_code": { "type": "integer" @@ -387,7 +364,7 @@ "type": "string" }, "upTime": { - "$ref": "#/components/schemas/time.Duration" + "type": "integer" }, "userName": { "type": "string" @@ -449,12 +426,12 @@ "name": "Process Compose Discord Channel", "url": "https://discord.gg/S4xgmRSHdC" }, - "description": "This is a sample server Process Compose server.", + "description": "This is a sample Process Compose server.", "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, - "title": "Swagger Process Compose API", + "title": "Process Compose API", "version": "1.0" }, "openapi": "3.0.3", @@ -462,6 +439,7 @@ "/hostname": { "get": { "description": "Get process compose hostname", + "operationId": "GetHostName", "responses": { "200": { "content": { @@ -499,6 +477,7 @@ "/live": { "get": { "description": "Check if server is responding", + "operationId": "IsAlive", "responses": { "200": { "description": "OK" @@ -513,6 +492,7 @@ "/process": { "post": { "description": "Update porcess", + "operationId": "UpdateProcess", "responses": { "200": { "content": { @@ -547,6 +527,7 @@ "/process/info/{name}": { "get": { "description": "Retrieves the given process and its config", + "operationId": "GetProcessInfo", "parameters": [ { "description": "Process Name", @@ -592,6 +573,7 @@ "/process/logs/{name}/{endOffset}/{limit}": { "get": { "description": "Retrieves the process logs", + "operationId": "GetProcessLogs", "parameters": [ { "description": "Process Name", @@ -661,6 +643,7 @@ "/process/ports/{name}": { "get": { "description": "Retrieves process open ports", + "operationId": "GetProcessPorts", "parameters": [ { "description": "Process Name", @@ -706,6 +689,7 @@ "/process/restart/{name}": { "post": { "description": "Restarts the process", + "operationId": "RestartProcess", "parameters": [ { "description": "Process Name", @@ -754,6 +738,7 @@ "/process/scale/{name}/{scale}": { "patch": { "description": "Scale a process", + "operationId": "ScaleProcess", "parameters": [ { "description": "Process Name", @@ -811,6 +796,7 @@ "/process/start/{name}": { "post": { "description": "Starts the process if the state is not 'running' or 'pending'", + "operationId": "StartProcess", "parameters": [ { "description": "Process Name", @@ -859,6 +845,7 @@ "/process/stop/{name}": { "patch": { "description": "Sends kill signal to the process", + "operationId": "StopProcess", "parameters": [ { "description": "Process Name", @@ -907,6 +894,7 @@ "/process/{name}": { "get": { "description": "Retrieves the given process and its status", + "operationId": "GetProcess", "parameters": [ { "description": "Process Name", @@ -952,6 +940,7 @@ "/processes": { "get": { "description": "Retrieves all the configured processes and their status", + "operationId": "GetProcesses", "responses": { "200": { "content": { @@ -986,9 +975,10 @@ "/processes/stop": { "patch": { "description": "Sends kill signal to the processes list", + "operationId": "StopProcesses", "requestBody": { "content": { - "*/*": { + "application/json": { "schema": { "items": { "type": "string" @@ -1051,6 +1041,7 @@ "/project": { "post": { "description": "Update running project", + "operationId": "UpdateProject", "responses": { "200": { "content": { @@ -1101,6 +1092,7 @@ "/project/configuration": { "post": { "description": "Reload project state from config", + "operationId": "ReloadProject", "responses": { "200": { "content": { @@ -1151,6 +1143,7 @@ "/project/state": { "get": { "description": "Retrieves project state information", + "operationId": "GetProjectState", "responses": { "200": { "content": { @@ -1185,6 +1178,7 @@ "/project/stop": { "post": { "description": "Shuts down the server", + "operationId": "ShutDownProject", "responses": { "200": { "content": { @@ -1206,5 +1200,10 @@ ] } } - } + }, + "servers": [ + { + "url": "https://localhost:8080/" + } + ] } \ No newline at end of file diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index bc9db28..7455d48 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -37,26 +37,6 @@ components: timeoutSeconds: type: integer type: object - time.Duration: - enum: - - -9.223372036854776e+18 - - 9223372036854776000 - - 1 - - 1000 - - 1000000 - - 1000000000 - - 60000000000 - - 3600000000000 - type: integer - x-enum-varnames: - - minDuration - - maxDuration - - Nanosecond - - Microsecond - - Millisecond - - Second - - Minute - - Hour types.DependsOnConfig: additionalProperties: $ref: '#/components/schemas/types.ProcessDependency' @@ -215,7 +195,7 @@ components: types.ProcessState: properties: age: - $ref: '#/components/schemas/time.Duration' + type: integer exit_code: type: integer is_elevated: @@ -265,7 +245,7 @@ components: startTime: type: string upTime: - $ref: '#/components/schemas/time.Duration' + type: integer userName: type: string version: @@ -304,17 +284,18 @@ info: contact: name: Process Compose Discord Channel url: https://discord.gg/S4xgmRSHdC - description: This is a sample server Process Compose server. + description: This is a sample Process Compose server. license: name: Apache 2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html - title: Swagger Process Compose API + title: Process Compose API version: "1.0" openapi: 3.0.3 paths: /hostname: get: description: Get process compose hostname + operationId: GetHostName responses: "200": content: @@ -338,6 +319,7 @@ paths: /live: get: description: Check if server is responding + operationId: IsAlive responses: "200": description: OK @@ -347,6 +329,7 @@ paths: /process: post: description: Update porcess + operationId: UpdateProcess responses: "200": content: @@ -368,6 +351,7 @@ paths: /process/{name}: get: description: Retrieves the given process and its status + operationId: GetProcess parameters: - description: Process Name in: path @@ -396,6 +380,7 @@ paths: /process/info/{name}: get: description: Retrieves the given process and its config + operationId: GetProcessInfo parameters: - description: Process Name in: path @@ -424,6 +409,7 @@ paths: /process/logs/{name}/{endOffset}/{limit}: get: description: Retrieves the process logs + operationId: GetProcessLogs parameters: - description: Process Name in: path @@ -468,6 +454,7 @@ paths: /process/ports/{name}: get: description: Retrieves process open ports + operationId: GetProcessPorts parameters: - description: Process Name in: path @@ -496,6 +483,7 @@ paths: /process/restart/{name}: post: description: Restarts the process + operationId: RestartProcess parameters: - description: Process Name in: path @@ -526,6 +514,7 @@ paths: /process/scale/{name}/{scale}: patch: description: Scale a process + operationId: ScaleProcess parameters: - description: Process Name in: path @@ -562,6 +551,7 @@ paths: /process/start/{name}: post: description: Starts the process if the state is not 'running' or 'pending' + operationId: StartProcess parameters: - description: Process Name in: path @@ -592,6 +582,7 @@ paths: /process/stop/{name}: patch: description: Sends kill signal to the process + operationId: StopProcess parameters: - description: Process Name in: path @@ -622,6 +613,7 @@ paths: /processes: get: description: Retrieves all the configured processes and their status + operationId: GetProcesses responses: "200": content: @@ -643,9 +635,10 @@ paths: /processes/stop: patch: description: Sends kill signal to the processes list + operationId: StopProcesses requestBody: content: - '*/*': + application/json: schema: items: type: string @@ -684,6 +677,7 @@ paths: /project: post: description: Update running project + operationId: UpdateProject responses: "200": content: @@ -715,6 +709,7 @@ paths: /project/configuration: post: description: Reload project state from config + operationId: ReloadProject responses: "200": content: @@ -746,6 +741,7 @@ paths: /project/state: get: description: Retrieves project state information + operationId: GetProjectState responses: "200": content: @@ -767,6 +763,7 @@ paths: /project/stop: post: description: Shuts down the server + operationId: ShutDownProject responses: "200": content: @@ -779,3 +776,5 @@ paths: summary: Stops all the processes and the server tags: - Project +servers: + - url: https://localhost:8080/ diff --git a/src/types/process.go b/src/types/process.go index 7606afc..3aca43c 100644 --- a/src/types/process.go +++ b/src/types/process.go @@ -202,7 +202,7 @@ type ProcessState struct { Namespace string `json:"namespace"` Status string `json:"status"` SystemTime string `json:"system_time"` - Age time.Duration `json:"age"` + Age time.Duration `json:"age" swaggertype:"primitive,integer"` Health string `json:"is_ready"` Restarts int `json:"restarts"` ExitCode int `json:"exit_code"` diff --git a/src/types/project_state.go b/src/types/project_state.go index 19c36b2..ba9eccb 100644 --- a/src/types/project_state.go +++ b/src/types/project_state.go @@ -4,7 +4,7 @@ import "time" type ProjectState struct { FileNames []string `json:"fileNames"` - UpTime time.Duration `json:"upTime"` + UpTime time.Duration `json:"upTime" swaggertype:"primitive,integer"` StartTime time.Time `json:"startTime"` ProcessNum int `json:"processNum"` RunningProcessNum int `json:"runningProcessNum"`