Skip to content

Commit

Permalink
Updated code generator to use native OpenAPI specification
Browse files Browse the repository at this point in the history
Signed-off-by: saimedhi <[email protected]>
  • Loading branch information
saimedhi committed Apr 17, 2024
1 parent bb5b545 commit 0b50dfc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
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

0 comments on commit 0b50dfc

Please sign in to comment.