weaviate

Форк
0
/
extendresponses.js 
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

7
const fs = require('fs')
8

9
const file = fs.readFileSync('./schema.json', 'utf-8')
10
const parsed = JSON.parse(file)
11

12
for (const [pathKey, pathValue] of Object.entries(parsed.paths)) {
13
  for (const [path, value] of Object.entries(pathValue)) {
14
    if (!value.responses) {
15
      continue
16
    }
17

18
    value.responses['500'] = {
19
      description: "An error has occurred while trying to fulfill the request. Most likely the ErrorResponse will contain more information about the error.",
20
      schema: {
21
        "$ref": "#/definitions/ErrorResponse"
22
      }
23
    }
24
  }
25
}
26
fs.writeFileSync('./schema.json', JSON.stringify(parsed, null, 2))
27

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.