Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[draft] Use a git submodule to include the OpenSearch.openapi.json file #627

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "specifications/opensearch-api-specification"]
path = specifications/opensearch-api-specification
url = https://github.com/opensearch-project/opensearch-api-specification.git/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 0 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
requests>=2, <3
pytest
pytest-cov
coverage
Expand Down
2 changes: 2 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions specifications/opensearch-api-specification
8 changes: 3 additions & 5 deletions utils/generate_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

import black
import deepmerge
import requests
import unasync
import urllib3
from click.testing import CliRunner
Expand Down Expand Up @@ -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 = []

Expand Down
Loading