I want to describe the route /get for socketio. the request looks like:
["get",{"id":"66ab972245a202801187dce8"}]
and the response
["answer",{"id":"66ab972245a202801187dce8", ...}
I already have a scheme for the answer and id.
I started to describe it like this
"/get": {
"post": {
"tags": ["widgets"],
"summary": "ws://localhost:8080",
"operationId": "getWidget",
"servers": [
{
"url": "ws://localhost:8080"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SocketWidgetRequest"
}
}
}
},
"responses": {
"200": {
"description": "Widget details.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SocketWidgetResponse"
}
}
}
}
}
}
}
"SocketWidgetResponse": {
"type": "array",
"items": [
{
"type": "string",
"example": "answer"
},
{
"$ref": "#/components/schemas/GetWidgetResponse"
}
]
},
"SocketWidgetRequest": {
"type": "array",
"items": [
{
"type": "string",
"example": "get"
},
{
"$ref": "#/components/schemas/Id"
}
]
}
the scheme for the id:
"Id": {
"type": "object",
"properties": {
"id": {
"type": "string",
"nullable": true
}
}
}
the layout for the widget
"GetWidgetResponse": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"title": {
"type": "object"
},
"folderId": {
"type": "string",
"nullable": true
},
"icon": {
"type": "string",
"nullable": true
},
"data": {
"type": "object"
},
"type": {
"type": "string"
}
}
}
and my swager is empty in the example value field:
I need to do it somehow, but I have no idea how to do it beautifully, correctly and clearly