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

feat(rpc): OpenAPI spec #8342

Merged
merged 2 commits into from
Mar 14, 2024
Merged

feat(rpc): OpenAPI spec #8342

merged 2 commits into from
Mar 14, 2024

Conversation

oxarbitrage
Copy link
Contributor

@oxarbitrage oxarbitrage commented Mar 11, 2024

Motivation

As part of the hackaton sprint i went over developing a swagger API for zebra RPC methods. I tried different rust tools initially but they didn't went too well so i decided to create an utility that can extract the information needed from the documentation in the Rust code and create a specification with that.

The result of that is in this PR, it is a bit fragile and needs some more work but i think is a good start.

PR Author Checklist

Check before marking the PR as ready for review:

  • Will the PR name make sense to users?
  • Does the PR have a priority label?
  • Have you added or updated tests?
  • Is the documentation up to date?

Solution

The generator will scrape data from the rust docs files to get the information needed to generate the open api spec. This code is a bit fragile and can be improved. This results in a binary called openapi-generator in the zebra-utils crate.

There is a lot of changes to method documentations to make them fit in the needed format, i tried to not make it very different than what we already had.

There are some defaults added to types so we can show example responses.

Testing

Manually. You can run the generator and paste the output into https://editor.swagger.io/

Review

Anyone can review.

Reviewer Checklist

Check before approving the PR:

  • Does the PR scope match the ticket?
  • Are there enough tests to make sure it works? Do the tests cover the PR motivation?
  • Are all the PR blockers dealt with?
    PR blockers can be dealt with in new tickets or PRs.

And check the PR Author checklist is complete.

Follow Up Work

  • There are some TODOs in the code.
  • The gRPC methods from the scanner are not included. For these the documentation is in the proto files and there are some tools to transform that to an openapi spec, so it should be a matter of adding that command at the end of the script and append the output.

@oxarbitrage oxarbitrage added A-docs Area: Documentation A-rpc Area: Remote Procedure Call interfaces P-Low ❄️ labels Mar 11, 2024
@oxarbitrage oxarbitrage self-assigned this Mar 11, 2024
@github-actions github-actions bot added the C-feature Category: New features label Mar 11, 2024
@oxarbitrage oxarbitrage marked this pull request as ready for review March 11, 2024 20:07
@oxarbitrage oxarbitrage requested review from a team as code owners March 11, 2024 20:07
@oxarbitrage oxarbitrage requested review from upbqdn and removed request for a team March 11, 2024 20:07
@gustavovalverde
Copy link
Member

This is lovely! ❤️

upbqdn
upbqdn previously approved these changes Mar 14, 2024
Copy link
Member

@upbqdn upbqdn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing. A great foundation for #8324.

zebra-utils/README.md Outdated Show resolved Hide resolved
Co-authored-by: Marek <mail@marek.onl>
Copy link
Member

@upbqdn upbqdn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, thanks for the thorough comments describing the parsing process.

mergify bot added a commit that referenced this pull request Mar 14, 2024
@mergify mergify bot merged commit f2be73e into main Mar 14, 2024
189 checks passed
@mergify mergify bot deleted the rpc-docs branch March 14, 2024 15:04
@mpguerra mpguerra linked an issue Mar 15, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation A-rpc Area: Remote Procedure Call interfaces C-feature Category: New features P-Low ❄️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add(rpc): Create documentation resource for all RPCs
3 participants