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: improve jsonschema types for protobuf well known types #254

Merged
merged 1 commit into from
Jul 12, 2021

Conversation

grant
Copy link
Contributor

@grant grant commented Jul 11, 2021

Fixes #250

Uses PROTOC_PLUGIN_VERSION=1.0.0.

  • Better JSON representation for google.protobuf.Value
  • Better JSON representation for google.protobuf.Duration

This should result in better parsing for these well known types, and types that aren't always JSON objects (hence the oneOf).

See: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf

Gen'd updates to language clients would follow this PR. Unfortunately the oneOf syntax isn't the greatest with quicktype. Although it is the most accurate for the JSON (not everything is an object), and easier to deal with downstream. Look at the protobuf docs for your own assessment.

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
@grant grant requested a review from jskeet July 11, 2021 23:45
@grant grant self-assigned this Jul 11, 2021
@grant grant requested a review from a team as a code owner July 11, 2021 23:45
@product-auto-label product-auto-label bot added the api: eventarc Issues related to the googleapis/google-cloudevents API. label Jul 11, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 11, 2021
Copy link
Collaborator

@jskeet jskeet left a comment

Choose a reason for hiding this comment

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

Happy with bytes and Value - I think Duration still needs some work though.

"additionalProperties": true,
"type": "object",
"type": "string",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm slightly surprised there's no format part here - does this mean there's no way of a JSON schema consumer telling the difference between a duration and a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We currently don't have it but we can add the formatting in the future.

Filed chrusty/protoc-gen-jsonschema#66

Copy link
Collaborator

@jskeet jskeet left a comment

Choose a reason for hiding this comment

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

(Approving as it's definitely better than before.)

gcf-merge-on-green bot pushed a commit to googleapis/google-cloudevents-nodejs that referenced this pull request Jul 12, 2021
Generation from updated schemas: googleapis/google-cloudevents#254

Should allow proper typing for Cloud Build types for example.
@grant grant added the automerge Merge the pull request once unit tests and other checks pass. label Jul 12, 2021
@gcf-merge-on-green gcf-merge-on-green bot merged commit e59a4bf into master Jul 12, 2021
@gcf-merge-on-green gcf-merge-on-green bot deleted the grant_jsonschema_update_2021_07 branch July 12, 2021 18:32
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Jul 12, 2021
gcf-merge-on-green bot pushed a commit that referenced this pull request Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: eventarc Issues related to the googleapis/google-cloudevents API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON schema google.protobuf.Duration Should Be Treated as string
2 participants