I’m studying Express and I built a simple application that searches the MariaDB database, and returns all the data in JSON. using compression returns 2MB of data, in total there are two thousand records. When testing the request and the swagger crashes, the error RESULT_CODE_HUNG occurs. Here is the json used in the configuration
{
"openapi": "3.0.0",
"info": {
"title": "API",
"description": "API to return database information",
"version": "1.0.0"
},
"servers": [
{
"url": "http://localhost:3000",
"description": "Server"
}
],
"paths": {
"/allresults": {
"get": {
"summary": "Returns all results from database",
"responses": {
"200": {
"description": "Request succcessfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TestData"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"TestData": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"service": {
"type": "string"
},
"ping": {
"type": "number"
},
"download": {
"type": "integer"
},
"upload": {
"type": "integer"
},
"comments": {
"type": "string",
"nullable": true
},
"data": {
"$ref": "#/components/schemas/TestDetails"
},
"status": {
"type": "string"
},
"scheduled": {
"type": "integer"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"updated_at": {
"type": "string",
"format": "date-time"
}
}
},
"TestDetails": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"timestamp": {
"type": "string",
"format": "date-time"
},
"ping": {
"$ref": "#/components/schemas/PingData"
},
"download": {
"$ref": "#/components/schemas/DownloadData"
},
"upload": {
"$ref": "#/components/schemas/UploadData"
},
"packetLoss": {
"type": "number"
},
"isp": {
"type": "string"
},
"interface": {
"$ref": "#/components/schemas/InterfaceData"
},
"server": {
"$ref": "#/components/schemas/ServerData"
},
"result": {
"$ref": "#/components/schemas/ResultData"
}
}
},
"PingData": {
"type": "object",
"properties": {
"jitter": {
"type": "number"
},
"latency": {
"type": "number"
},
"low": {
"type": "number"
},
"high": {
"type": "number"
}
}
},
"DownloadData": {
"type": "object",
"properties": {
"bandwidth": {
"type": "integer"
},
"bytes": {
"type": "integer"
},
"elapsed": {
"type": "integer"
},
"latency": {
"$ref": "#/components/schemas/LatencyData"
}
}
},
"UploadData": {
"type": "object",
"properties": {
"bandwidth": {
"type": "integer"
},
"bytes": {
"type": "integer"
},
"elapsed": {
"type": "integer"
},
"latency": {
"$ref": "#/components/schemas/LatencyData"
}
}
},
"LatencyData": {
"type": "object",
"properties": {
"iqm": {
"type": "number"
},
"low": {
"type": "number"
},
"high": {
"type": "number"
},
"jitter": {
"type": "number"
}
}
},
"InterfaceData": {
"type": "object",
"properties": {
"internalIp": {
"type": "string",
"format": "ipv4"
},
"name": {
"type": "string"
},
"macAddr": {
"type": "string"
},
"isVpn": {
"type": "boolean"
},
"externalIp": {
"type": "string",
"format": "ipv4"
}
}
},
"ServerData": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"host": {
"type": "string"
},
"port": {
"type": "integer"
},
"name": {
"type": "string"
},
"location": {
"type": "string"
},
"country": {
"type": "string"
},
"ip": {
"type": "string",
"format": "ipv4"
}
}
},
"ResultData": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"url": {
"type": "string",
"format": "uri"
},
"persisted": {
"type": "boolean"
}
}
}
}
}
}
Swagger use in server.js
const swaggerDocument = require('./swagger.json');
app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(swaggerDocument))
New contributor
Leonald Eufrasio Junior is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.