diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..cd474451 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "specifications/opensearch-api-specification"] + path = specifications/opensearch-api-specification + url = https://github.com/opensearch-project/opensearch-api-specification.git/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 092e0e3f..95edec50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added a log collection guide ([#579](https://github.com/opensearch-project/opensearch-py/pull/579)) - Added GHA release ([#614](https://github.com/opensearch-project/opensearch-py/pull/614)) ### Changed +- Read the `OpenSearch.openapi.json` API specification file from a `git` submodule checkout instead of making an HTTP request. ([#627](https://github.com/opensearch-project/opensearch-py/pull/627)) ### Deprecated ### Removed - Removed unnecessary `# -*- coding: utf-8 -*-` headers from .py files ([#615](https://github.com/opensearch-project/opensearch-py/pull/615), [#617](https://github.com/opensearch-project/opensearch-py/pull/617)) diff --git a/dev-requirements.txt b/dev-requirements.txt index a79a1a0b..0ed01404 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,3 @@ -requests>=2, <3 pytest pytest-cov coverage diff --git a/noxfile.py b/noxfile.py index d453a3a2..b6f840d3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -118,6 +118,8 @@ def docs(session: Any) -> None: @nox.session() # type: ignore def generate(session: Any) -> None: + session.run("git", "submodule", "init", external=True) + session.run("git", "submodule", "update", external=True) session.install("-rdev-requirements.txt") session.run("python", "utils/generate_api.py") format(session) diff --git a/specifications/opensearch-api-specification b/specifications/opensearch-api-specification new file mode 160000 index 00000000..14193807 --- /dev/null +++ b/specifications/opensearch-api-specification @@ -0,0 +1 @@ +Subproject commit 141938072013af422f48f67eaf847ce1398f13e9 diff --git a/utils/generate_api.py b/utils/generate_api.py index d671a975..3777fa70 100644 --- a/utils/generate_api.py +++ b/utils/generate_api.py @@ -41,7 +41,6 @@ import black import deepmerge -import requests import unasync import urllib3 from click.testing import CliRunner @@ -429,10 +428,9 @@ def read_modules() -> Any: modules = {} # Load the OpenAPI specification file - response = requests.get( - "https://raw.githubusercontent.com/opensearch-project/opensearch-api-specification/main/OpenSearch.openapi.json" - ) - data = response.json() + path = "specifications/opensearch-api-specification/OpenSearch.openapi.json" + with open(path) as f: + data = json.loads(f.read()) list_of_dicts = []