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

Updated code generator to use native OpenAPI specification #37

Merged
merged 1 commit into from
Apr 17, 2024
Merged
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Removed
- Removed support for Python 3.6, 3.7 ([#717](https://github.com/opensearch-project/opensearch-py/pull/717))
### Fixed
- Updated code generator to use new version of OpenAPI specification ([#721](https://github.com/opensearch-project/opensearch-py/pull/721))
- Updated code generator to use native OpenAPI specification ([#721](https://github.com/opensearch-project/opensearch-py/pull/721))
### Updated APIs
### Security
### Dependencies
Expand Down
9 changes: 5 additions & 4 deletions utils/changelog_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ def main() -> None:
or "Changes not staged for commit:" in git_status.decode()
or "Untracked files:" in git_status.decode()
):
print("Changes detected")
response = requests.get(
"https://api.github.com/repos/opensearch-project/opensearch-api-specification/commits"
)
print("Changes detected; updating changelog.")

base_url = "https://api.github.com/repos/opensearch-project/opensearch-api-specification/commits"
url_with_per_page = base_url + "?per_page=1"
response = requests.get(url_with_per_page)
if response.ok:
commit_info = response.json()[0]
commit_url = commit_info["html_url"]
Expand Down
18 changes: 17 additions & 1 deletion utils/generate_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,22 @@ def all_parts(self) -> Dict[str, str]:
if self.namespace == "tasks" and self.name == "get":
parts["task_id"]["required"] = False

# Workaround to prevent lint error: invalid escape sequence '\`'
if (
self.namespace == "indices"
and self.name == "create_data_stream"
and part == "name"
):
replace_str = r"`\`, "
# Replace the string in the description
parts["name"]["description"] = parts["name"]["description"].replace(
replace_str, ""
)
if "backslash" not in parts["name"]["description"]:
parts["name"]["description"] = parts["name"]["description"].replace(
"`:`", "`:`, backslash"
)

for k, sub in SUBSTITUTIONS.items():
if k in parts:
parts[sub] = parts.pop(k)
Expand Down Expand Up @@ -645,7 +661,7 @@ def read_modules() -> Any:

if "description" in part:
parts_dict.update(
{"description": part["description"].replace("\n", "")}
{"description": part["description"].replace("\n", " ")}
)

if "x-enum-options" in part["schema"]:
Expand Down
Loading