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

Add endpoint URLs to the API specification (phase 1) #3469

Merged
merged 4 commits into from
Jan 15, 2025
Merged

Conversation

swallez
Copy link
Member

@swallez swallez commented Jan 8, 2025

The endpoints' URL path templates and http methods are currently missing from the API spec (TypeScript source) and are imported from the json rest-spec when the spec if compiled to schema.json. This means that the API spec currently does not contain all the information defining the API.

This PR allows endpoint URLs to be captured in request definitions in the API spec. The format follows that of the json rest-spec and schema.json:

export interface Request extends RequestBase {
  urls: [
    {
      /** @deprecated 1.2.3 Use something else */
      path: '/some/path/{part}',
      methods: ["GET", "POST"]
    }
  ]
  path_parts: {
    part: ...

This PR also includes a code modification utility to automatically add this information to the API spec from json rest-spec. Only two endpoints have been updated to test and demonstrate this utility. The full update will be done in a subsequent PR so that this one can be backported to other branches.

This PR is split in several commits:

  • 775f49d adds the code modification utility that adds URL paths to API spec requests.
  • 146d0ed updates the compiler to handle the additional urls field, along with validation.
  • a463d22 updates two request definitions with the utility mentioned above. This is the result of running
    echo '../specification/_global/clear_scroll/ClearScrollRequest.ts
    ../specification/_global/bulk/BulkRequest.ts' | (cd compiler-rs; cargo run --bin add_url_paths ../output/schema/schema.json | sh)
    The spec is also compiled, and we can see that the only changed are location information in these two requests because of the added urls property.
  • 070c15f updates the docs with the new urls.

Copy link
Contributor

github-actions bot commented Jan 8, 2025

Following you can find the validation results for the APIs you have changed.

API Status Request Response
bulk 🟢 445/445 463/463
clear_scroll 🟢 17/17 17/17

You can validate these APIs yourself by using the make validate target.

Copy link
Contributor

github-actions bot commented Jan 9, 2025

Following you can find the validation results for the APIs you have changed.

API Status Request Response
bulk 🟢 445/445 463/463
clear_scroll 🟢 17/17 17/17

You can validate these APIs yourself by using the make validate target.

Copy link
Contributor

github-actions bot commented Jan 9, 2025

Following you can find the validation results for the APIs you have changed.

API Status Request Response
bulk 🟢 445/445 463/463
clear_scroll 🟢 17/17 17/17

You can validate these APIs yourself by using the make validate target.

@flobernd
Copy link
Member

The JS compiler part looks good 🙂

@swallez swallez merged commit c23216f into main Jan 15, 2025
10 checks passed
@swallez swallez deleted the add-request-paths branch January 15, 2025 11:29
Copy link
Contributor

The backport to 8.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-8.x 8.x
# Navigate to the new working tree
cd .worktrees/backport-8.x
# Create a new branch
git switch --create backport-3469-to-8.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 c23216f42349809f49383f84074df8bceb2e8bdf
# Push it to GitHub
git push --set-upstream origin backport-3469-to-8.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-8.x

Then, create a pull request where the base branch is 8.x and the compare/head branch is backport-3469-to-8.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants