weaviate
26 строк · 861.0 Байт
1/**
2* A simple script to add a new response to every single API path. This was
3* built for the purpose of adding 500 Internal Server Error to everything, but
4* could potentially also be used for other purposes in the future.
5*/
6
7const fs = require('fs')8
9const file = fs.readFileSync('./schema.json', 'utf-8')10const parsed = JSON.parse(file)11
12for (const [pathKey, pathValue] of Object.entries(parsed.paths)) {13for (const [path, value] of Object.entries(pathValue)) {14if (!value.responses) {15continue16}17
18value.responses['500'] = {19description: "An error has occurred while trying to fulfill the request. Most likely the ErrorResponse will contain more information about the error.",20schema: {21"$ref": "#/definitions/ErrorResponse"22}23}24}25}
26fs.writeFileSync('./schema.json', JSON.stringify(parsed, null, 2))27