haystack
1#!/usr/bin/env python3
2
3import json4from pathlib import Path5import os6import sys7
8import logging9
10logging.basicConfig(level=logging.INFO)11
12
13sys.path.append(".")14from rest_api.utils import get_openapi_specs, get_app, get_pipelines # pylint: disable=wrong-import-position15from haystack import __version__ # pylint: disable=wrong-import-position16
17REST_PATH = Path("./rest_api/rest_api").absolute()18PIPELINE_PATH = str(REST_PATH / "pipeline" / "pipeline_empty.haystack-pipeline.yml")19APP_PATH = str(REST_PATH / "application.py")20
21os.environ["PIPELINE_YAML_PATH"] = PIPELINE_PATH22
23logging.info("Loading OpenAPI specs from %s with pipeline at %s", APP_PATH, PIPELINE_PATH)24
25# To initialize the app and the pipelines
26get_app()27get_pipelines()28
29# Generate the openapi specs
30specs = 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)
32specs.update({"x-readme": {"proxy-enabled": False, "samples-languages": ["curl", "python"]}})33
34# Dump the specs into a JSON file
35with open("openapi.json", "w") as f:36json.dump(specs, f, indent=4)37f.write("\n") # We need to add a newline, otherwise there will be a conflict with end-of-file-fixer pre-commit hook38