Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(openapi): migrate to openapi(swagger) 3.0 from 2.0 #253

Closed
dzmitry-lahoda opened this issue Sep 26, 2024 · 19 comments
Closed

feat(openapi): migrate to openapi(swagger) 3.0 from 2.0 #253

dzmitry-lahoda opened this issue Sep 26, 2024 · 19 comments
Labels
enhancement New feature or request

Comments

@dzmitry-lahoda
Copy link

dzmitry-lahoda commented Sep 26, 2024

Feature Request

Migrate openapi (swagger) generator to openapi 3.0

Use Case:

I am Rust develop. All rust developers develop crypto.

And have not time to develop process-compose like thing (all attempts stalled).

Also Go people are very experienced in process orchestration things

So it is reasonable to just use Process Compose from Rust via Open API.

But Rust crates which render idiomatic rust like progenitor and okapi work only with Open API 3+, not 2.

Proposed Change:

Use Go mod to generate 3.0 OpenAPI

Who Benefits From The Change(s)?

  • All who use openapi 3.0, and cannot 2.0
  • All who wants to migrate to 3.0 as it is strictly better and safes and more precise (better generated clients).

Alternative Approaches

  • GRPC API (will fix better structured return schemas, not they are just objects)

  • yaml first approach (will fix better structured return schemas, not they are just objects)

  • convert v2 to v3 via https://github.com/getkin/kin-openapi (I am on it now, checking if it slick). UPDATE: it is not cmdcli, need to type Go code. tried https://converter.swagger.io/#/Converter/convertByContent and it converted to invalid output as (un)expected. UPDATE2: seems useless as can only produce untyped JSON in return

@dzmitry-lahoda
Copy link
Author

Will donate 100 USD equivalent in crypto for this feature.

@dzmitry-lahoda
Copy link
Author

Current generator seems tries to gen more valid swagger, but I do not see now next fields in master in json

// @title Process Compose API
// @version 1.0
// @description process compose description

@dzmitry-lahoda
Copy link
Author

Seems gin swagger max is // @Produce json, so pretty useless open API.

Found only one OPI 3.0 for Go as of now, but it different http framwork, https://github.com/a-h/rest .

@dzmitry-lahoda
Copy link
Author

dzmitry-lahoda commented Sep 26, 2024

@F1bonacc1 what do you think about these things?

@dzmitry-lahoda
Copy link
Author

There are several approaches to generate Swagger from GRPC if that route is possible. I have seen some in Google Agones gameservers and Cosmos SDK blochchain repos (written in Go)

@F1bonacc1
Copy link
Owner

Hi @dzmitry-lahoda,

Can you provide a bit more information? What would be an acceptable result of this?

  1. To have an always up-to-date swagger.json or swagger.yaml in OpenAPI 3 format here? Or
  2. To have an OpenAPI 3 webApp on http://localhost:8080/? Or
  3. Both.

If it's only 1, can you please confirm if this is what you are looking for:

OpenAPI 3
{
    "components": {},
    "info": {
        "contact": {
            "name": "Eugene Berger",
            "url": "https://f1bonacc1.github.io/process-compose/"
        },
        "description": "This is a sample server Process Compose server.",
        "license": {
            "name": "Apache 2.0",
            "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
        },
        "title": "Swagger Process Compose API",
        "version": "1.0"
    },
    "openapi": "3.0.3",
    "paths": {
        "/hostname": {
            "get": {
                "description": "Get process compose hostname",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                },
                "summary": "Get Hostname",
                "tags": [
                    "Hostname"
                ]
            }
        },
        "/live": {
            "get": {
                "description": "Check if server is responding",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                },
                "summary": "Liveness Check",
                "tags": [
                    "Liveness"
                ]
            }
        },
        "/process": {
            "post": {
                "description": "Update porcess",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                },
                "summary": "Updates process configuration",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/info/{name}": {
            "get": {
                "description": "Retrieves the given process and its config",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Process Config"
                    }
                },
                "summary": "Get process config",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/logs/{name}/{endOffset}/{limit}": {
            "get": {
                "description": "Retrieves the process logs",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "description": "Offset from the end of the log",
                        "in": "path",
                        "name": "endOffset",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "description": "Limit of lines to get (0 will get all the lines till the end)",
                        "in": "path",
                        "name": "limit",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Process Logs"
                    }
                },
                "summary": "Get process logs",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/ports/{name}": {
            "get": {
                "description": "Retrieves process open ports",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Process Ports"
                    }
                },
                "summary": "Get process ports",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/restart/{name}": {
            "post": {
                "description": "Restarts the process",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        },
                        "description": "Restarted Process Name"
                    }
                },
                "summary": "Restart a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/scale/{name}/{scale}": {
            "patch": {
                "description": "Scale a process",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "description": "New amount of process replicas",
                        "in": "path",
                        "name": "scale",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        },
                        "description": "Scaled Process Name"
                    }
                },
                "summary": "Scale a process to a given replicas count",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/start/{name}": {
            "post": {
                "description": "Starts the process if the state is not 'running' or 'pending'",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        },
                        "description": "Started Process Name"
                    }
                },
                "summary": "Start a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/stop/{name}": {
            "patch": {
                "description": "Sends kill signal to the process",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        },
                        "description": "Stopped Process Name"
                    }
                },
                "summary": "Stop a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/{name}": {
            "get": {
                "description": "Retrieves the given process and its status",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Process State"
                    }
                },
                "summary": "Get process state",
                "tags": [
                    "Process"
                ]
            }
        },
        "/processes": {
            "get": {
                "description": "Retrieves all the configured processes and their status",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Processes Status"
                    }
                },
                "summary": "Get all processes",
                "tags": [
                    "Process"
                ]
            }
        },
        "/processes/stop": {
            "patch": {
                "description": "Sends kill signal to the processes list",
                "requestBody": {
                    "content": {
                        "*/*": {
                            "schema": {
                                "items": {
                                    "type": "string"
                                },
                                "type": "array"
                            }
                        }
                    },
                    "description": "Processes Names",
                    "required": true,
                    "x-originalParamName": "[]string"
                },
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        },
                        "description": "Stopped Processes Names"
                    }
                },
                "summary": "Stop processes",
                "tags": [
                    "Process"
                ]
            }
        },
        "/project": {
            "post": {
                "description": "Update running project",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                },
                "summary": "Updates running processes",
                "tags": [
                    "Project"
                ]
            }
        },
        "/project/state": {
            "get": {
                "description": "Retrieves project state information",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Project State"
                    }
                },
                "summary": "Get project state",
                "tags": [
                    "Project"
                ]
            }
        },
        "/project/stop": {
            "post": {
                "description": "Shuts down the server",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                },
                "summary": "Stops all the processes and the server",
                "tags": [
                    "Project"
                ]
            }
        }
    }
}

If this is acceptable I will find an automated way to keep it up to date for each release.

@F1bonacc1 F1bonacc1 added the enhancement New feature or request label Sep 27, 2024
@dzmitry-lahoda
Copy link
Author

  1. Always(consistent commit) up to date swagger.ANY in OpenAPI 3 in docs so I can use it #draft feat(rust): added crate genenerated with api #256
  2. I need for client generation as part of rust build, so not going to run PC, so no need live webapp, even local. So can curl json to file and get client generate too.

So only ONE.

For migrated examples:

                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        },

Returns are just raw jsons, so it makes generation less useful. How to make returns values also into OpenAPI defintion?

@F1bonacc1
Copy link
Owner

F1bonacc1 commented Sep 28, 2024

Good feedback.
I added more annotations to json generation.

What do you think about this?

OpenAPI 3
{
    "components": {
        "schemas": {
            "health.ExecProbe": {
                "properties": {
                    "command": {
                        "type": "string"
                    },
                    "workingDir": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "health.HttpProbe": {
                "properties": {
                    "host": {
                        "type": "string"
                    },
                    "numPort": {
                        "type": "integer"
                    },
                    "path": {
                        "type": "string"
                    },
                    "port": {
                        "type": "string"
                    },
                    "scheme": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "health.Probe": {
                "properties": {
                    "exec": {
                        "$ref": "#/components/schemas/health.ExecProbe"
                    },
                    "failureThreshold": {
                        "type": "integer"
                    },
                    "httpGet": {
                        "$ref": "#/components/schemas/health.HttpProbe"
                    },
                    "initialDelay": {
                        "type": "integer"
                    },
                    "periodSeconds": {
                        "type": "integer"
                    },
                    "successThreshold": {
                        "type": "integer"
                    },
                    "timeoutSeconds": {
                        "type": "integer"
                    }
                },
                "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"
                },
                "type": "object"
            },
            "types.LogRotationConfig": {
                "properties": {
                    "compress": {
                        "description": "Compress determines if the rotated log files should be compressed\nusing gzip. The default is not to perform compression.",
                        "type": "boolean"
                    },
                    "directory": {
                        "description": "Directory to log to when filelogging is enabled",
                        "type": "string"
                    },
                    "filename": {
                        "description": "Filename is the name of the logfile which will be placed inside the directory",
                        "type": "string"
                    },
                    "maxAge": {
                        "description": "MaxAge the max age in days to keep a logfile",
                        "type": "integer"
                    },
                    "maxBackups": {
                        "description": "MaxBackups the max number of rolled files to keep",
                        "type": "integer"
                    },
                    "maxSize": {
                        "description": "MaxSize the max size in MB of the logfile before it's rolled",
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "types.LoggerConfig": {
                "properties": {
                    "addTimestamp": {
                        "description": "AddTimestamp adds timestamp to log",
                        "type": "boolean"
                    },
                    "disableJSON": {
                        "description": "DisableJSON disables log JSON formatting",
                        "type": "boolean"
                    },
                    "fieldsOrder": {
                        "description": "FieldsOrder is the order in which fields are logged",
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "flushEachLine": {
                        "description": "FlushEachLine flushes the logger on each line",
                        "type": "boolean"
                    },
                    "noColor": {
                        "description": "NoColor disables coloring",
                        "type": "boolean"
                    },
                    "noMetadata": {
                        "description": "NoMetadata disables log metadata (process, replica)",
                        "type": "boolean"
                    },
                    "rotation": {
                        "allOf": [
                            {
                                "$ref": "#/components/schemas/types.LogRotationConfig"
                            }
                        ],
                        "description": "Rotation is the configuration for logging rotation"
                    },
                    "timestampFormat": {
                        "description": "TimestampFormat is the format of the timestamp",
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.MemoryState": {
                "properties": {
                    "allocated": {
                        "type": "integer"
                    },
                    "gcCycles": {
                        "type": "integer"
                    },
                    "systemMemory": {
                        "type": "integer"
                    },
                    "totalAllocated": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "types.ProcessConfig": {
                "properties": {
                    "args": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "command": {
                        "type": "string"
                    },
                    "dependsOn": {
                        "$ref": "#/components/schemas/types.DependsOnConfig"
                    },
                    "description": {
                        "type": "string"
                    },
                    "disableAnsiColors": {
                        "type": "boolean"
                    },
                    "disabled": {
                        "type": "boolean"
                    },
                    "entrypoint": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "environment": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "executable": {
                        "type": "string"
                    },
                    "extensions": {
                        "additionalProperties": true,
                        "type": "object"
                    },
                    "isDaemon": {
                        "type": "boolean"
                    },
                    "isElevated": {
                        "type": "boolean"
                    },
                    "isForeground": {
                        "type": "boolean"
                    },
                    "isTty": {
                        "type": "boolean"
                    },
                    "livenessProbe": {
                        "$ref": "#/components/schemas/health.Probe"
                    },
                    "logLocation": {
                        "type": "string"
                    },
                    "loggerConfig": {
                        "$ref": "#/components/schemas/types.LoggerConfig"
                    },
                    "name": {
                        "type": "string"
                    },
                    "namespace": {
                        "type": "string"
                    },
                    "readinessProbe": {
                        "$ref": "#/components/schemas/health.Probe"
                    },
                    "readyLogLine": {
                        "type": "string"
                    },
                    "replicaName": {
                        "type": "string"
                    },
                    "replicaNum": {
                        "type": "integer"
                    },
                    "replicas": {
                        "type": "integer"
                    },
                    "restartPolicy": {
                        "$ref": "#/components/schemas/types.RestartPolicyConfig"
                    },
                    "shutDownParams": {
                        "$ref": "#/components/schemas/types.ShutDownParams"
                    },
                    "vars": {
                        "$ref": "#/components/schemas/types.Vars"
                    },
                    "workingDir": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.ProcessDependency": {
                "properties": {
                    "condition": {
                        "type": "string"
                    },
                    "extensions": {
                        "additionalProperties": true,
                        "type": "object"
                    }
                },
                "type": "object"
            },
            "types.ProcessPorts": {
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "tcp_ports": {
                        "items": {
                            "type": "integer"
                        },
                        "type": "array"
                    },
                    "udp_ports": {
                        "items": {
                            "type": "integer"
                        },
                        "type": "array"
                    }
                },
                "type": "object"
            },
            "types.ProcessState": {
                "properties": {
                    "age": {
                        "$ref": "#/components/schemas/time.Duration"
                    },
                    "exit_code": {
                        "type": "integer"
                    },
                    "isRunning": {
                        "type": "boolean"
                    },
                    "is_elevated": {
                        "type": "boolean"
                    },
                    "is_ready": {
                        "type": "string"
                    },
                    "mem": {
                        "type": "integer"
                    },
                    "name": {
                        "type": "string"
                    },
                    "namespace": {
                        "type": "string"
                    },
                    "password_provided": {
                        "type": "boolean"
                    },
                    "pid": {
                        "type": "integer"
                    },
                    "restarts": {
                        "type": "integer"
                    },
                    "status": {
                        "type": "string"
                    },
                    "system_time": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.ProcessesState": {
                "properties": {
                    "data": {
                        "items": {
                            "$ref": "#/components/schemas/types.ProcessState"
                        },
                        "type": "array"
                    }
                },
                "type": "object"
            },
            "types.ProjectState": {
                "properties": {
                    "fileNames": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "hostName": {
                        "type": "string"
                    },
                    "memoryState": {
                        "$ref": "#/components/schemas/types.MemoryState"
                    },
                    "processNum": {
                        "type": "integer"
                    },
                    "runningProcessNum": {
                        "type": "integer"
                    },
                    "startTime": {
                        "type": "string"
                    },
                    "upTime": {
                        "$ref": "#/components/schemas/time.Duration"
                    },
                    "userName": {
                        "type": "string"
                    },
                    "version": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.RestartPolicyConfig": {
                "properties": {
                    "backoffSeconds": {
                        "type": "integer"
                    },
                    "exitOnEnd": {
                        "type": "boolean"
                    },
                    "exitOnSkipped": {
                        "type": "boolean"
                    },
                    "maxRestarts": {
                        "type": "integer"
                    },
                    "restart": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.ShutDownParams": {
                "properties": {
                    "parentOnly": {
                        "type": "boolean"
                    },
                    "shutDownCommand": {
                        "type": "string"
                    },
                    "shutDownTimeout": {
                        "type": "integer"
                    },
                    "signal": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "types.Vars": {
                "additionalProperties": {},
                "type": "object"
            }
        }
    },
    "info": {
        "contact": {
            "name": "Eugene Berger",
            "url": "https://f1bonacc1.github.io/process-compose/"
        },
        "description": "This is a sample server Process Compose server.",
        "license": {
            "name": "Apache 2.0",
            "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
        },
        "title": "Swagger Process Compose API",
        "version": "1.0"
    },
    "openapi": "3.0.3",
    "paths": {
        "/hostname": {
            "get": {
                "description": "Get process compose hostname",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Hostname"
                    }
                },
                "summary": "Get Hostname",
                "tags": [
                    "Hostname"
                ]
            }
        },
        "/live": {
            "get": {
                "description": "Check if server is responding",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                },
                "summary": "Liveness Check",
                "tags": [
                    "Liveness"
                ]
            }
        },
        "/process": {
            "post": {
                "description": "Update porcess",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessConfig"
                                }
                            }
                        },
                        "description": "Updated Process Config"
                    }
                },
                "summary": "Updates process configuration",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/info/{name}": {
            "get": {
                "description": "Retrieves the given process and its config",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessConfig"
                                }
                            }
                        },
                        "description": "OK"
                    }
                },
                "summary": "Get process config",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/logs/{name}/{endOffset}/{limit}": {
            "get": {
                "description": "Retrieves the process logs",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "description": "Offset from the end of the log",
                        "in": "path",
                        "name": "endOffset",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "description": "Limit of lines to get (0 will get all the lines till the end)",
                        "in": "path",
                        "name": "limit",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "items": {
                                            "type": "string"
                                        },
                                        "type": "array"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Process Logs"
                    }
                },
                "summary": "Get process logs",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/ports/{name}": {
            "get": {
                "description": "Retrieves process open ports",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessPorts"
                                }
                            }
                        },
                        "description": "Process Ports"
                    }
                },
                "summary": "Get process ports",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/restart/{name}": {
            "post": {
                "description": "Restarts the process",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Restarted Process Name"
                    }
                },
                "summary": "Restart a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/scale/{name}/{scale}": {
            "patch": {
                "description": "Scale a process",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "description": "New amount of process replicas",
                        "in": "path",
                        "name": "scale",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Scaled Process Name"
                    }
                },
                "summary": "Scale a process to a given replicas count",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/start/{name}": {
            "post": {
                "description": "Starts the process if the state is not 'running' or 'pending'",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Started Process Name"
                    }
                },
                "summary": "Start a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/stop/{name}": {
            "patch": {
                "description": "Sends kill signal to the process",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Stopped Process Name"
                    }
                },
                "summary": "Stop a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/{name}": {
            "get": {
                "description": "Retrieves the given process and its status",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessState"
                                }
                            }
                        },
                        "description": "OK"
                    }
                },
                "summary": "Get process state",
                "tags": [
                    "Process"
                ]
            }
        },
        "/processes": {
            "get": {
                "description": "Retrieves all the configured processes and their status",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessesState"
                                }
                            }
                        },
                        "description": "Processes Status"
                    }
                },
                "summary": "Get all processes",
                "tags": [
                    "Process"
                ]
            }
        },
        "/processes/stop": {
            "patch": {
                "description": "Sends kill signal to the processes list",
                "requestBody": {
                    "content": {
                        "*/*": {
                            "schema": {
                                "items": {
                                    "type": "string"
                                },
                                "type": "array"
                            }
                        }
                    },
                    "description": "Processes Names",
                    "required": true,
                    "x-originalParamName": "[]string"
                },
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Stopped Processes Names"
                    }
                },
                "summary": "Stop processes",
                "tags": [
                    "Process"
                ]
            }
        },
        "/project": {
            "post": {
                "description": "Update running project",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Update Project Status"
                    }
                },
                "summary": "Updates running processes",
                "tags": [
                    "Project"
                ]
            }
        },
        "/project/state": {
            "get": {
                "description": "Retrieves project state information",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProjectState"
                                }
                            }
                        },
                        "description": "Project State"
                    }
                },
                "summary": "Get project state",
                "tags": [
                    "Project"
                ]
            }
        },
        "/project/stop": {
            "post": {
                "description": "Shuts down the server",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Stopped Server"
                    }
                },
                "summary": "Stops all the processes and the server",
                "tags": [
                    "Project"
                ]
            }
        }
    }
}

@dzmitry-lahoda
Copy link
Author

oh, so fast :) thank you

I tried and got to this: oxidecomputer/progenitor#694 (comment)

//Compiling process-compose-openapi-client v0.1.0 (/home/dz/github.com/F1bonacc1/process-compose/crates/openapi-client)
// error: generation error for ../../src/docs/swagger.3.json: unexpected or unhandled format in the OpenAPI document path /hostname is missing operation ID
// --> src/lib.rs:2:22
// |
// 2 | generate_api!(spec = "../../src/docs/swagger.3.json");
// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

// error: could not compile process-compose-openapi-client (lib) due to 1 previous error
// warning: build failed, waiting for other jobs to finish...

So operation id is used to name Rust methods. Is it easy to add?

@dzmitry-lahoda
Copy link
Author

And yes - REFs instead of raw json is good way for Rust return types.

@F1bonacc1
Copy link
Owner

How about this one:

OpenAPI 3
{
    "components": {
        "schemas": {
            "health.ExecProbe": {
                "properties": {
                    "command": {
                        "type": "string"
                    },
                    "workingDir": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "health.HttpProbe": {
                "properties": {
                    "host": {
                        "type": "string"
                    },
                    "numPort": {
                        "type": "integer"
                    },
                    "path": {
                        "type": "string"
                    },
                    "port": {
                        "type": "string"
                    },
                    "scheme": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "health.Probe": {
                "properties": {
                    "exec": {
                        "$ref": "#/components/schemas/health.ExecProbe"
                    },
                    "failureThreshold": {
                        "type": "integer"
                    },
                    "httpGet": {
                        "$ref": "#/components/schemas/health.HttpProbe"
                    },
                    "initialDelay": {
                        "type": "integer"
                    },
                    "periodSeconds": {
                        "type": "integer"
                    },
                    "successThreshold": {
                        "type": "integer"
                    },
                    "timeoutSeconds": {
                        "type": "integer"
                    }
                },
                "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"
                },
                "type": "object"
            },
            "types.LogRotationConfig": {
                "properties": {
                    "compress": {
                        "description": "Compress determines if the rotated log files should be compressed\nusing gzip. The default is not to perform compression.",
                        "type": "boolean"
                    },
                    "directory": {
                        "description": "Directory to log to when filelogging is enabled",
                        "type": "string"
                    },
                    "filename": {
                        "description": "Filename is the name of the logfile which will be placed inside the directory",
                        "type": "string"
                    },
                    "maxAge": {
                        "description": "MaxAge the max age in days to keep a logfile",
                        "type": "integer"
                    },
                    "maxBackups": {
                        "description": "MaxBackups the max number of rolled files to keep",
                        "type": "integer"
                    },
                    "maxSize": {
                        "description": "MaxSize the max size in MB of the logfile before it's rolled",
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "types.LoggerConfig": {
                "properties": {
                    "addTimestamp": {
                        "description": "AddTimestamp adds timestamp to log",
                        "type": "boolean"
                    },
                    "disableJSON": {
                        "description": "DisableJSON disables log JSON formatting",
                        "type": "boolean"
                    },
                    "fieldsOrder": {
                        "description": "FieldsOrder is the order in which fields are logged",
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "flushEachLine": {
                        "description": "FlushEachLine flushes the logger on each line",
                        "type": "boolean"
                    },
                    "noColor": {
                        "description": "NoColor disables coloring",
                        "type": "boolean"
                    },
                    "noMetadata": {
                        "description": "NoMetadata disables log metadata (process, replica)",
                        "type": "boolean"
                    },
                    "rotation": {
                        "allOf": [
                            {
                                "$ref": "#/components/schemas/types.LogRotationConfig"
                            }
                        ],
                        "description": "Rotation is the configuration for logging rotation"
                    },
                    "timestampFormat": {
                        "description": "TimestampFormat is the format of the timestamp",
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.MemoryState": {
                "properties": {
                    "allocated": {
                        "type": "integer"
                    },
                    "gcCycles": {
                        "type": "integer"
                    },
                    "systemMemory": {
                        "type": "integer"
                    },
                    "totalAllocated": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "types.ProcessConfig": {
                "properties": {
                    "args": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "command": {
                        "type": "string"
                    },
                    "dependsOn": {
                        "$ref": "#/components/schemas/types.DependsOnConfig"
                    },
                    "description": {
                        "type": "string"
                    },
                    "disableAnsiColors": {
                        "type": "boolean"
                    },
                    "disabled": {
                        "type": "boolean"
                    },
                    "entrypoint": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "environment": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "executable": {
                        "type": "string"
                    },
                    "extensions": {
                        "additionalProperties": true,
                        "type": "object"
                    },
                    "isDaemon": {
                        "type": "boolean"
                    },
                    "isElevated": {
                        "type": "boolean"
                    },
                    "isForeground": {
                        "type": "boolean"
                    },
                    "isTty": {
                        "type": "boolean"
                    },
                    "livenessProbe": {
                        "$ref": "#/components/schemas/health.Probe"
                    },
                    "logLocation": {
                        "type": "string"
                    },
                    "loggerConfig": {
                        "$ref": "#/components/schemas/types.LoggerConfig"
                    },
                    "name": {
                        "type": "string"
                    },
                    "namespace": {
                        "type": "string"
                    },
                    "readinessProbe": {
                        "$ref": "#/components/schemas/health.Probe"
                    },
                    "readyLogLine": {
                        "type": "string"
                    },
                    "replicaName": {
                        "type": "string"
                    },
                    "replicaNum": {
                        "type": "integer"
                    },
                    "replicas": {
                        "type": "integer"
                    },
                    "restartPolicy": {
                        "$ref": "#/components/schemas/types.RestartPolicyConfig"
                    },
                    "shutDownParams": {
                        "$ref": "#/components/schemas/types.ShutDownParams"
                    },
                    "vars": {
                        "$ref": "#/components/schemas/types.Vars"
                    },
                    "workingDir": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.ProcessDependency": {
                "properties": {
                    "condition": {
                        "type": "string"
                    },
                    "extensions": {
                        "additionalProperties": true,
                        "type": "object"
                    }
                },
                "type": "object"
            },
            "types.ProcessPorts": {
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "tcp_ports": {
                        "items": {
                            "type": "integer"
                        },
                        "type": "array"
                    },
                    "udp_ports": {
                        "items": {
                            "type": "integer"
                        },
                        "type": "array"
                    }
                },
                "type": "object"
            },
            "types.ProcessState": {
                "properties": {
                    "age": {
                        "$ref": "#/components/schemas/time.Duration"
                    },
                    "exit_code": {
                        "type": "integer"
                    },
                    "isRunning": {
                        "type": "boolean"
                    },
                    "is_elevated": {
                        "type": "boolean"
                    },
                    "is_ready": {
                        "type": "string"
                    },
                    "mem": {
                        "type": "integer"
                    },
                    "name": {
                        "type": "string"
                    },
                    "namespace": {
                        "type": "string"
                    },
                    "password_provided": {
                        "type": "boolean"
                    },
                    "pid": {
                        "type": "integer"
                    },
                    "restarts": {
                        "type": "integer"
                    },
                    "status": {
                        "type": "string"
                    },
                    "system_time": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.ProcessesState": {
                "properties": {
                    "data": {
                        "items": {
                            "$ref": "#/components/schemas/types.ProcessState"
                        },
                        "type": "array"
                    }
                },
                "type": "object"
            },
            "types.ProjectState": {
                "properties": {
                    "fileNames": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "hostName": {
                        "type": "string"
                    },
                    "memoryState": {
                        "$ref": "#/components/schemas/types.MemoryState"
                    },
                    "processNum": {
                        "type": "integer"
                    },
                    "runningProcessNum": {
                        "type": "integer"
                    },
                    "startTime": {
                        "type": "string"
                    },
                    "upTime": {
                        "$ref": "#/components/schemas/time.Duration"
                    },
                    "userName": {
                        "type": "string"
                    },
                    "version": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.RestartPolicyConfig": {
                "properties": {
                    "backoffSeconds": {
                        "type": "integer"
                    },
                    "exitOnEnd": {
                        "type": "boolean"
                    },
                    "exitOnSkipped": {
                        "type": "boolean"
                    },
                    "maxRestarts": {
                        "type": "integer"
                    },
                    "restart": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.ShutDownParams": {
                "properties": {
                    "parentOnly": {
                        "type": "boolean"
                    },
                    "shutDownCommand": {
                        "type": "string"
                    },
                    "shutDownTimeout": {
                        "type": "integer"
                    },
                    "signal": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "types.Vars": {
                "additionalProperties": {},
                "type": "object"
            }
        }
    },
    "externalDocs": {
        "url": "https://f1bonacc1.github.io/process-compose/"
    },
    "info": {
        "contact": {
            "name": "Process Compose Discord Channel",
            "url": "https://discord.gg/S4xgmRSHdC"
        },
        "description": "This is a sample server Process Compose server.",
        "license": {
            "name": "Apache 2.0",
            "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
        },
        "title": "Swagger Process Compose API",
        "version": "1.0"
    },
    "openapi": "3.0.3",
    "paths": {
        "/hostname": {
            "get": {
                "description": "Get process compose hostname",
                "operationId": "GetHostName",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Hostname"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get Hostname",
                "tags": [
                    "Hostname"
                ]
            }
        },
        "/live": {
            "get": {
                "description": "Check if server is responding",
                "operationId": "IsAlive",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                },
                "summary": "Liveness Check",
                "tags": [
                    "Liveness"
                ]
            }
        },
        "/process": {
            "post": {
                "description": "Update porcess",
                "operationId": "UpdateProcess",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessConfig"
                                }
                            }
                        },
                        "description": "Updated Process Config"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Updates process configuration",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/info/{name}": {
            "get": {
                "description": "Retrieves the given process and its config",
                "operationId": "GetProcessInfo",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessConfig"
                                }
                            }
                        },
                        "description": "OK"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get process config",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/logs/{name}/{endOffset}/{limit}": {
            "get": {
                "description": "Retrieves the process logs",
                "operationId": "GetProcessLogs",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "description": "Offset from the end of the log",
                        "in": "path",
                        "name": "endOffset",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "description": "Limit of lines to get (0 will get all the lines till the end)",
                        "in": "path",
                        "name": "limit",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "items": {
                                            "type": "string"
                                        },
                                        "type": "array"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Process Logs"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get process logs",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/ports/{name}": {
            "get": {
                "description": "Retrieves process open ports",
                "operationId": "GetProcessPorts",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessPorts"
                                }
                            }
                        },
                        "description": "Process Ports"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get process ports",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/restart/{name}": {
            "post": {
                "description": "Restarts the process",
                "operationId": "RestartProcess",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Restarted Process Name"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Restart a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/scale/{name}/{scale}": {
            "patch": {
                "description": "Scale a process",
                "operationId": "ScaleProcess",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "description": "New amount of process replicas",
                        "in": "path",
                        "name": "scale",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Scaled Process Name"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Scale a process to a given replicas count",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/start/{name}": {
            "post": {
                "description": "Starts the process if the state is not 'running' or 'pending'",
                "operationId": "StartProcess",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Started Process Name"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Start a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/stop/{name}": {
            "patch": {
                "description": "Sends kill signal to the process",
                "operationId": "StopProcess",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Stopped Process Name"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Stop a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/{name}": {
            "get": {
                "description": "Retrieves the given process and its status",
                "operationId": "GetProcess",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessState"
                                }
                            }
                        },
                        "description": "OK"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get process state",
                "tags": [
                    "Process"
                ]
            }
        },
        "/processes": {
            "get": {
                "description": "Retrieves all the configured processes and their status",
                "operationId": "GetProcesses",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessesState"
                                }
                            }
                        },
                        "description": "Processes Status"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get all processes",
                "tags": [
                    "Process"
                ]
            }
        },
        "/processes/stop": {
            "patch": {
                "description": "Sends kill signal to the processes list",
                "operationId": "StopProcesses",
                "requestBody": {
                    "content": {
                        "*/*": {
                            "schema": {
                                "items": {
                                    "type": "string"
                                },
                                "type": "array"
                            }
                        }
                    },
                    "description": "Processes Names",
                    "required": true,
                    "x-originalParamName": "[]string"
                },
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Stopped Processes Names"
                    },
                    "207": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Stopped Processes Names"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Stop processes",
                "tags": [
                    "Process"
                ]
            }
        },
        "/project": {
            "post": {
                "description": "Update running project",
                "operationId": "UpdateProject",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Update Project Status"
                    },
                    "207": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Update Project Status"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Updates running processes",
                "tags": [
                    "Project"
                ]
            }
        },
        "/project/configuration": {
            "post": {
                "description": "Reload project state from config",
                "operationId": "ReloadProject",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Update Project Status"
                    },
                    "207": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Update Project Status"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Reload project",
                "tags": [
                    "Project"
                ]
            }
        },
        "/project/state": {
            "get": {
                "description": "Retrieves project state information",
                "operationId": "GetProjectState",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProjectState"
                                }
                            }
                        },
                        "description": "Project State"
                    },
                    "500": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Internal Server Error"
                    }
                },
                "summary": "Get project state",
                "tags": [
                    "Project"
                ]
            }
        },
        "/project/stop": {
            "post": {
                "description": "Shuts down the server",
                "operationId": "ShutDownProject",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Stopped Server"
                    }
                },
                "summary": "Stops all the processes and the server",
                "tags": [
                    "Project"
                ]
            }
        }
    }
}

@dzmitry-lahoda
Copy link
Author

got this

bash-5.1$ cargo test
   Compiling process-compose-openapi-client v0.1.0 (/home/dz/github.com/F1bonacc1/process-compose/crates/openapi-client)
error: generation error for ../../src/docs/swagger.3.json: type error value does not conform to the given schema
 --> src/lib.rs:2:22
  |
2 | generate_api!(spec = "../../src/docs/swagger.3.json");
  |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `process-compose-openapi-client` (lib)

seems oxidecomputer/typify#611 (comment)

@dzmitry-lahoda
Copy link
Author

so https://validator.swagger.io/#/Validator/validateByContent says swagger is valid. checking

@dzmitry-lahoda
Copy link
Author

@F1bonacc1 this thing Rust cannot handle


          "time.Duration": {
              "enum": [
                  -9223372036854776000,
                  9223372036854776000,
                  1,
                  1000,
                  1000000,
                  1000000000,
                  60000000000,
                  3600000000000
              ],
              "type": "integer",
              "x-enum-varnames": [
                  "minDuration",
                  "maxDuration",
                  "Nanosecond",
                  "Microsecond",
                  "Millisecond",
                  "Second",
                  "Minute",
                  "Hour"
              ]
          },

Not sure what is it?

@dzmitry-lahoda
Copy link
Author

   Compiling process-compose-openapi-client v0.1.0 (/home/dz/github.com/F1bonacc1/process-compose/crates/openapi-client)
error: generation error for ../../src/docs/swagger.3.json: unexpected or unhandled format in the OpenAPI document unexpected content type: */*
 --> src/lib.rs:3:10

for

              "requestBody": {
                  "content": {
                      "*/*": {
                          "schema": {
                              "items": {
                                  "type": "string"
                              },
                              "type": "array"
                          }
                      }
                  },

@dzmitry-lahoda
Copy link
Author

I pushed changes to PR which fully work - duration was set to be integer and content to be specific - json.

@F1bonacc1 btw, may we make Rust gen a part of CI ? ;) Seems it very good test proving that other languages will generate well too.

@F1bonacc1
Copy link
Owner

@dzmitry-lahoda
Can you check this one?

OpenAPI 3
{
    "components": {
        "schemas": {
            "health.ExecProbe": {
                "properties": {
                    "command": {
                        "type": "string"
                    },
                    "workingDir": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "health.HttpProbe": {
                "properties": {
                    "host": {
                        "type": "string"
                    },
                    "numPort": {
                        "type": "integer"
                    },
                    "path": {
                        "type": "string"
                    },
                    "port": {
                        "type": "string"
                    },
                    "scheme": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "health.Probe": {
                "properties": {
                    "exec": {
                        "$ref": "#/components/schemas/health.ExecProbe"
                    },
                    "failureThreshold": {
                        "type": "integer"
                    },
                    "httpGet": {
                        "$ref": "#/components/schemas/health.HttpProbe"
                    },
                    "initialDelay": {
                        "type": "integer"
                    },
                    "periodSeconds": {
                        "type": "integer"
                    },
                    "successThreshold": {
                        "type": "integer"
                    },
                    "timeoutSeconds": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "types.DependsOnConfig": {
                "additionalProperties": {
                    "$ref": "#/components/schemas/types.ProcessDependency"
                },
                "type": "object"
            },
            "types.LogRotationConfig": {
                "properties": {
                    "compress": {
                        "description": "Compress determines if the rotated log files should be compressed\nusing gzip. The default is not to perform compression.",
                        "type": "boolean"
                    },
                    "directory": {
                        "description": "Directory to log to when filelogging is enabled",
                        "type": "string"
                    },
                    "filename": {
                        "description": "Filename is the name of the logfile which will be placed inside the directory",
                        "type": "string"
                    },
                    "maxAge": {
                        "description": "MaxAge the max age in days to keep a logfile",
                        "type": "integer"
                    },
                    "maxBackups": {
                        "description": "MaxBackups the max number of rolled files to keep",
                        "type": "integer"
                    },
                    "maxSize": {
                        "description": "MaxSize the max size in MB of the logfile before it's rolled",
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "types.LoggerConfig": {
                "properties": {
                    "addTimestamp": {
                        "description": "AddTimestamp adds timestamp to log",
                        "type": "boolean"
                    },
                    "disableJSON": {
                        "description": "DisableJSON disables log JSON formatting",
                        "type": "boolean"
                    },
                    "fieldsOrder": {
                        "description": "FieldsOrder is the order in which fields are logged",
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "flushEachLine": {
                        "description": "FlushEachLine flushes the logger on each line",
                        "type": "boolean"
                    },
                    "noColor": {
                        "description": "NoColor disables coloring",
                        "type": "boolean"
                    },
                    "noMetadata": {
                        "description": "NoMetadata disables log metadata (process, replica)",
                        "type": "boolean"
                    },
                    "rotation": {
                        "allOf": [
                            {
                                "$ref": "#/components/schemas/types.LogRotationConfig"
                            }
                        ],
                        "description": "Rotation is the configuration for logging rotation"
                    },
                    "timestampFormat": {
                        "description": "TimestampFormat is the format of the timestamp",
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.MemoryState": {
                "properties": {
                    "allocated": {
                        "type": "integer"
                    },
                    "gcCycles": {
                        "type": "integer"
                    },
                    "systemMemory": {
                        "type": "integer"
                    },
                    "totalAllocated": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "types.ProcessConfig": {
                "properties": {
                    "args": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "command": {
                        "type": "string"
                    },
                    "dependsOn": {
                        "$ref": "#/components/schemas/types.DependsOnConfig"
                    },
                    "description": {
                        "type": "string"
                    },
                    "disableAnsiColors": {
                        "type": "boolean"
                    },
                    "disabled": {
                        "type": "boolean"
                    },
                    "entrypoint": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "environment": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "executable": {
                        "type": "string"
                    },
                    "extensions": {
                        "additionalProperties": true,
                        "type": "object"
                    },
                    "isDaemon": {
                        "type": "boolean"
                    },
                    "isElevated": {
                        "type": "boolean"
                    },
                    "isForeground": {
                        "type": "boolean"
                    },
                    "isTty": {
                        "type": "boolean"
                    },
                    "livenessProbe": {
                        "$ref": "#/components/schemas/health.Probe"
                    },
                    "logLocation": {
                        "type": "string"
                    },
                    "loggerConfig": {
                        "$ref": "#/components/schemas/types.LoggerConfig"
                    },
                    "name": {
                        "type": "string"
                    },
                    "namespace": {
                        "type": "string"
                    },
                    "readinessProbe": {
                        "$ref": "#/components/schemas/health.Probe"
                    },
                    "readyLogLine": {
                        "type": "string"
                    },
                    "replicaName": {
                        "type": "string"
                    },
                    "replicaNum": {
                        "type": "integer"
                    },
                    "replicas": {
                        "type": "integer"
                    },
                    "restartPolicy": {
                        "$ref": "#/components/schemas/types.RestartPolicyConfig"
                    },
                    "shutDownParams": {
                        "$ref": "#/components/schemas/types.ShutDownParams"
                    },
                    "vars": {
                        "$ref": "#/components/schemas/types.Vars"
                    },
                    "workingDir": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.ProcessDependency": {
                "properties": {
                    "condition": {
                        "type": "string"
                    },
                    "extensions": {
                        "additionalProperties": true,
                        "type": "object"
                    }
                },
                "type": "object"
            },
            "types.ProcessPorts": {
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "tcp_ports": {
                        "items": {
                            "type": "integer"
                        },
                        "type": "array"
                    },
                    "udp_ports": {
                        "items": {
                            "type": "integer"
                        },
                        "type": "array"
                    }
                },
                "type": "object"
            },
            "types.ProcessState": {
                "properties": {
                    "age": {
                        "type": "integer"
                    },
                    "exit_code": {
                        "type": "integer"
                    },
                    "isRunning": {
                        "type": "boolean"
                    },
                    "is_elevated": {
                        "type": "boolean"
                    },
                    "is_ready": {
                        "type": "string"
                    },
                    "mem": {
                        "type": "integer"
                    },
                    "name": {
                        "type": "string"
                    },
                    "namespace": {
                        "type": "string"
                    },
                    "password_provided": {
                        "type": "boolean"
                    },
                    "pid": {
                        "type": "integer"
                    },
                    "restarts": {
                        "type": "integer"
                    },
                    "status": {
                        "type": "string"
                    },
                    "system_time": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.ProcessesState": {
                "properties": {
                    "data": {
                        "items": {
                            "$ref": "#/components/schemas/types.ProcessState"
                        },
                        "type": "array"
                    }
                },
                "type": "object"
            },
            "types.ProjectState": {
                "properties": {
                    "fileNames": {
                        "items": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "hostName": {
                        "type": "string"
                    },
                    "memoryState": {
                        "$ref": "#/components/schemas/types.MemoryState"
                    },
                    "processNum": {
                        "type": "integer"
                    },
                    "runningProcessNum": {
                        "type": "integer"
                    },
                    "startTime": {
                        "type": "string"
                    },
                    "upTime": {
                        "type": "integer"
                    },
                    "userName": {
                        "type": "string"
                    },
                    "version": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.RestartPolicyConfig": {
                "properties": {
                    "backoffSeconds": {
                        "type": "integer"
                    },
                    "exitOnEnd": {
                        "type": "boolean"
                    },
                    "exitOnSkipped": {
                        "type": "boolean"
                    },
                    "maxRestarts": {
                        "type": "integer"
                    },
                    "restart": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "types.ShutDownParams": {
                "properties": {
                    "parentOnly": {
                        "type": "boolean"
                    },
                    "shutDownCommand": {
                        "type": "string"
                    },
                    "shutDownTimeout": {
                        "type": "integer"
                    },
                    "signal": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "types.Vars": {
                "additionalProperties": {},
                "type": "object"
            }
        }
    },
    "externalDocs": {
        "url": "https://f1bonacc1.github.io/process-compose/"
    },
    "info": {
        "contact": {
            "name": "Process Compose Discord Channel",
            "url": "https://discord.gg/S4xgmRSHdC"
        },
        "description": "This is a sample server Process Compose server.",
        "license": {
            "name": "Apache 2.0",
            "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
        },
        "title": "Swagger Process Compose API",
        "version": "1.0"
    },
    "openapi": "3.0.3",
    "paths": {
        "/hostname": {
            "get": {
                "description": "Get process compose hostname",
                "operationId": "GetHostName",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Hostname"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get Hostname",
                "tags": [
                    "Hostname"
                ]
            }
        },
        "/live": {
            "get": {
                "description": "Check if server is responding",
                "operationId": "IsAlive",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                },
                "summary": "Liveness Check",
                "tags": [
                    "Liveness"
                ]
            }
        },
        "/process": {
            "post": {
                "description": "Update porcess",
                "operationId": "UpdateProcess",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessConfig"
                                }
                            }
                        },
                        "description": "Updated Process Config"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Updates process configuration",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/info/{name}": {
            "get": {
                "description": "Retrieves the given process and its config",
                "operationId": "GetProcessInfo",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessConfig"
                                }
                            }
                        },
                        "description": "OK"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get process config",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/logs/{name}/{endOffset}/{limit}": {
            "get": {
                "description": "Retrieves the process logs",
                "operationId": "GetProcessLogs",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "description": "Offset from the end of the log",
                        "in": "path",
                        "name": "endOffset",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "description": "Limit of lines to get (0 will get all the lines till the end)",
                        "in": "path",
                        "name": "limit",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "items": {
                                            "type": "string"
                                        },
                                        "type": "array"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Process Logs"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get process logs",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/ports/{name}": {
            "get": {
                "description": "Retrieves process open ports",
                "operationId": "GetProcessPorts",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessPorts"
                                }
                            }
                        },
                        "description": "Process Ports"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get process ports",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/restart/{name}": {
            "post": {
                "description": "Restarts the process",
                "operationId": "RestartProcess",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Restarted Process Name"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Restart a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/scale/{name}/{scale}": {
            "patch": {
                "description": "Scale a process",
                "operationId": "ScaleProcess",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "description": "New amount of process replicas",
                        "in": "path",
                        "name": "scale",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Scaled Process Name"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Scale a process to a given replicas count",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/start/{name}": {
            "post": {
                "description": "Starts the process if the state is not 'running' or 'pending'",
                "operationId": "StartProcess",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Started Process Name"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Start a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/stop/{name}": {
            "patch": {
                "description": "Sends kill signal to the process",
                "operationId": "StopProcess",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Stopped Process Name"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Stop a process",
                "tags": [
                    "Process"
                ]
            }
        },
        "/process/{name}": {
            "get": {
                "description": "Retrieves the given process and its status",
                "operationId": "GetProcess",
                "parameters": [
                    {
                        "description": "Process Name",
                        "in": "path",
                        "name": "name",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessState"
                                }
                            }
                        },
                        "description": "OK"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get process state",
                "tags": [
                    "Process"
                ]
            }
        },
        "/processes": {
            "get": {
                "description": "Retrieves all the configured processes and their status",
                "operationId": "GetProcesses",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProcessesState"
                                }
                            }
                        },
                        "description": "Processes Status"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Get all processes",
                "tags": [
                    "Process"
                ]
            }
        },
        "/processes/stop": {
            "patch": {
                "description": "Sends kill signal to the processes list",
                "operationId": "StopProcesses",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "items": {
                                    "type": "string"
                                },
                                "type": "array"
                            }
                        }
                    },
                    "description": "Processes Names",
                    "required": true,
                    "x-originalParamName": "[]string"
                },
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Stopped Processes Names"
                    },
                    "207": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Stopped Processes Names"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Stop processes",
                "tags": [
                    "Process"
                ]
            }
        },
        "/project": {
            "post": {
                "description": "Update running project",
                "operationId": "UpdateProject",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Update Project Status"
                    },
                    "207": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Update Project Status"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Updates running processes",
                "tags": [
                    "Project"
                ]
            }
        },
        "/project/configuration": {
            "post": {
                "description": "Reload project state from config",
                "operationId": "ReloadProject",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Update Project Status"
                    },
                    "207": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Update Project Status"
                    },
                    "400": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Bad Request"
                    }
                },
                "summary": "Reload project",
                "tags": [
                    "Project"
                ]
            }
        },
        "/project/state": {
            "get": {
                "description": "Retrieves project state information",
                "operationId": "GetProjectState",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/types.ProjectState"
                                }
                            }
                        },
                        "description": "Project State"
                    },
                    "500": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Internal Server Error"
                    }
                },
                "summary": "Get project state",
                "tags": [
                    "Project"
                ]
            }
        },
        "/project/stop": {
            "post": {
                "description": "Shuts down the server",
                "operationId": "ShutDownProject",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "type": "object"
                                }
                            }
                        },
                        "description": "Stopped Server"
                    }
                },
                "summary": "Stops all the processes and the server",
                "tags": [
                    "Project"
                ]
            }
        }
    }
}

If this one works for you I would prefer to add a golang based validation. It will be easier for me to maintain.

@dzmitry-lahoda dzmitry-lahoda changed the title feat(openapi): migrate to openapi(sagger) 3.0 from 2.0 feat(openapi): migrate to openapi(swagger) 3.0 from 2.0 Sep 29, 2024
@dzmitry-lahoda
Copy link
Author

last one schema worked well.

okey.

F1bonacc1 added a commit that referenced this issue Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants