-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[WIP] tooling: Add jsonschema dump of API #13283
Conversation
a83a3fc
to
da2bbcb
Compare
Signed-off-by: Ryan Northey <ryan@synca.io>
c43a7bf
to
8e0b6dc
Compare
@@ -10,3 +11,10 @@ go_proto_compiler( | |||
valid_archive = False, | |||
visibility = ["//visibility:public"], | |||
) | |||
|
|||
go_binary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this is correct/necessary - i figured we need to compile the lib/bin somewhere - locally i did it with make build
and then exporting ./bin
to PATH
"//tools/api_proto_plugin", | ||
"//tools/config_validation:validate_fragment", | ||
"@com_envoyproxy_protoc_gen_validate//validate:validate_py", | ||
"@com_github_chrusty_protoc_gen_jsonschema", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding this fails - im not sure how to include the lib so its visible to api_proto_plugin_impl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like one problem im hitting is because protoc_gen_jsonschema
doesnt have a bazel BUILD
file
im wondering if i need to "inject" a BUILD file as suggested here https://grpc.io/blog/bazel-rules-protobuf/#143-workspace-rules-that-accept-a-build-file-as-an-argument, or whether there is an easier way to include the compiled binary
also, not sure if/how its possible to use rules_proto
- i had a look at it - but im struggling to figure out how it can be used with protoc-gen-jsonschema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things:
- You probably do need to inject a BUILD file (or upstream one) to turn protoc-gen-jsonschema into a
go_binary
. - I think the interesting thing from api_proto_plugin isn't the Python framework, which doesn't really apply here, but the .bzl, i.e. tools/api_proto_plugin/plugin.bzl, which gives essentially a way to invoke some protoc plugin as an aspect.
- For
rules_proto
, I think you want to figure out how to useproto_plugin
based on how some of the language examples work in the repo, e.g.cpp_proto_compile
. If we go this route, we could either do an aspect like in (2), or modifyapi_proto_library
to also externalize a jsonscheme target for each proto library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im gonna have to get a better handle on how these components work independently of envoy repo - ill update once i have a vague clue what im doing...
@htuch i copied out the docs build (+ im not sure if i have removed stuff that is required - and almost certainly there is cruft left that still needs to be removed. im not quite sure how to procede from here - ive left a couple of comments inline - basically it downloads |
if [ -n "$CIRCLE_TAG" ] | ||
then | ||
# Check the git tag matches the version number in the VERSION file. | ||
VERSION_NUMBER=$(cat VERSION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you refactor with docs/build.sh to a util shell script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iiuc - yep
echo "Generating ${API_VERSION} API SCHEMA..." | ||
|
||
# Generate the extensions docs | ||
echo "RUNNING BAZEL BUILD WITH ASPECT..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Prefer not-all caps, too much shouting :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SORRY, DEBUGGING 8/
EXTENSION_DB_PATH="$(realpath "${BUILD_DIR}/extension_db.json")" | ||
export EXTENSION_DB_PATH | ||
|
||
# This is for local RBE setup, should be no-op for builds without RBE setting in bazelrc files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here for refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
"//tools/api_proto_plugin", | ||
"//tools/config_validation:validate_fragment", | ||
"@com_envoyproxy_protoc_gen_validate//validate:validate_py", | ||
"@com_github_chrusty_protoc_gen_jsonschema", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things:
- You probably do need to inject a BUILD file (or upstream one) to turn protoc-gen-jsonschema into a
go_binary
. - I think the interesting thing from api_proto_plugin isn't the Python framework, which doesn't really apply here, but the .bzl, i.e. tools/api_proto_plugin/plugin.bzl, which gives essentially a way to invoke some protoc plugin as an aspect.
- For
rules_proto
, I think you want to figure out how to useproto_plugin
based on how some of the language examples work in the repo, e.g.cpp_proto_compile
. If we go this route, we could either do an aspect like in (2), or modifyapi_proto_library
to also externalize a jsonscheme target for each proto library.
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
bump, im working on this |
Signed-off-by: Ryan Northey <ryan@synca.io>
with a lot of hackery i have kinda got this working locally i havent pushed the code yet, as its pretty messy, and doesnt work exactly to get it working i forked protoc-gen-jsonschema builds correctly and has all its deps afaict - and is being called in the the remaining problem seems to be that some of the p-g-j handles this by creating separate jsonschema files for each. Seems like bazel doesnt like that. |
after a bit more experimenting with this p-g-j creates files using the message name so eg if there is a file this allows for multiple messages or enums i need to clarify how jsonschema works in this respect - maybe we need to have multiple files for this. Atm bazel fails with this tho as it expects different outputs to get it ~working i hacked p-g-j and made it output to the expected file and skip any additional messages. It kinda works, other things fail, but most of the proto files get jsonschema files - not sure of their veracity at this stage |
@phlax Bazel's build graph needs to have known output files at each node. One technique that is sometimes used is to take multiple unknown output files and combine them into a single tar for the node. |
re i guess the main question im trying to answer atm is whether we can wrap and mangle the output from p-g-j (and potentially upstream any small changes that we need) - or whether our needs are quite specific and we are better off with a forked/hacked version ill keep playing with this and post updates |
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Signed-off-by: Ryan Northey ryan@synca.io
Commit Message: tooling: Add jsonschema dump of API
Additional Description:
Add jsonschema dump of API that can be consumed in tooling such as VSCode
Risk Level: low
Testing:
Docs Changes: to follow
Release Notes:
[Optional Runtime guard:]
[Optional Fixes #Issue] Fix #13254
[Optional Deprecated:]