haystack

Форк
0
/
generate_openapi_specs.py 
37 строк · 1.2 Кб
1
#!/usr/bin/env python3
2

3
import json
4
from pathlib import Path
5
import os
6
import sys
7

8
import logging
9

10
logging.basicConfig(level=logging.INFO)
11

12

13
sys.path.append(".")
14
from rest_api.utils import get_openapi_specs, get_app, get_pipelines  # pylint: disable=wrong-import-position
15
from haystack import __version__  # pylint: disable=wrong-import-position
16

17
REST_PATH = Path("./rest_api/rest_api").absolute()
18
PIPELINE_PATH = str(REST_PATH / "pipeline" / "pipeline_empty.haystack-pipeline.yml")
19
APP_PATH = str(REST_PATH / "application.py")
20

21
os.environ["PIPELINE_YAML_PATH"] = PIPELINE_PATH
22

23
logging.info("Loading OpenAPI specs from %s with pipeline at %s", APP_PATH, PIPELINE_PATH)
24

25
# To initialize the app and the pipelines
26
get_app()
27
get_pipelines()
28

29
# Generate the openapi specs
30
specs = get_openapi_specs()
31
# Add `x-readme` to disable proxy and limit sample languages on documentation (see https://docs.readme.com/main/docs/openapi-extensions)
32
specs.update({"x-readme": {"proxy-enabled": False, "samples-languages": ["curl", "python"]}})
33

34
# Dump the specs into a JSON file
35
with open("openapi.json", "w") as f:
36
    json.dump(specs, f, indent=4)
37
    f.write("\n")  # We need to add a newline, otherwise there will be a conflict with end-of-file-fixer pre-commit hook
38

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

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

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

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