Skip to content

Commit

Permalink
fix: JSON schema no bigint strings (#127)
Browse files Browse the repository at this point in the history
* feat: jsonschema bigints should not be strings

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

* fix: remove empty examples array

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

* fix: revert log changes

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
  • Loading branch information
grant authored Dec 14, 2020
1 parent 8349231 commit 1cdf408
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 42 deletions.
9 changes: 3 additions & 6 deletions jsonschema/google/events/cloud/audit/v1/LogEntryData.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"google.cloud.audit.log.v1.written"
],
"product": "Cloud Audit Logs",
"examples": [
"https://googleapis.github.io/google-cloudevents/testdata/google/events/cloud/audit/v1/LogEntryData-pubsubCreateTopic.json"
],
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"logName": {
Expand Down Expand Up @@ -91,7 +88,7 @@
"description": "The resource's original state before mutation. Present only for\n operations which have successfully modified the targeted resource(s).\n In general, this field should contain all changed fields, except those\n that are already been included in `request`, `response`, `metadata` or\n `service_data` fields.\n When the JSON object represented here has a proto equivalent,\n the proto name will be indicated in the `@type` property."
},
"numResponseItems": {
"type": "string",
"type": "integer",
"description": "The number of items returned from a List or Query API method,\n if applicable."
},
"status": {
Expand Down Expand Up @@ -345,7 +342,7 @@
"format": "date-time"
},
"size": {
"type": "string",
"type": "integer",
"description": "The HTTP request size in bytes. If unknown, it must be -1."
},
"protocol": {
Expand Down Expand Up @@ -418,7 +415,7 @@
"description": "The IP address of the peer."
},
"port": {
"type": "string",
"type": "integer",
"description": "The network port of the peer."
},
"labels": {
Expand Down
13 changes: 6 additions & 7 deletions jsonschema/google/events/cloud/cloudbuild/v1/BuildEventData.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"google.cloud.cloudbuild.build.v1.statusChanged"
],
"product": "Cloud Build",
"examples": [],
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"id": {
Expand Down Expand Up @@ -141,7 +140,7 @@
"timeout": {
"properties": {
"seconds": {
"type": "string",
"type": "integer",
"description": "Signed seconds of the span of time. Must be from -315,576,000,000\n to +315,576,000,000 inclusive. Note: these bounds are computed from:\n 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years"
},
"nanos": {
Expand Down Expand Up @@ -211,7 +210,7 @@
"description": "Path to the artifact manifest. Only populated when artifacts are uploaded."
},
"numArtifacts": {
"type": "string",
"type": "integer",
"description": "Number of artifacts uploaded. Only populated when artifacts are uploaded."
},
"buildStepOutputs": {
Expand Down Expand Up @@ -250,7 +249,7 @@
"timeout": {
"properties": {
"seconds": {
"type": "string",
"type": "integer",
"description": "Signed seconds of the span of time. Must be from -315,576,000,000\n to +315,576,000,000 inclusive. Note: these bounds are computed from:\n 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years"
},
"nanos": {
Expand All @@ -272,7 +271,7 @@
"queueTtl": {
"properties": {
"seconds": {
"type": "string",
"type": "integer",
"description": "Signed seconds of the span of time. Must be from -315,576,000,000\n to +315,576,000,000 inclusive. Note: these bounds are computed from:\n 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years"
},
"nanos": {
Expand Down Expand Up @@ -446,7 +445,7 @@
"description": "Compute Engine machine type on which to run the build."
},
"diskSizeGb": {
"type": "string",
"type": "integer",
"description": "Requested disk size for the VM that runs the build. Note that this is *NOT*\n \"disk free\"; some of the space will be used by the operating system and\n build utilities. Also note that this is the minimum disk size that will be\n allocated for the build -- the build may run with a larger disk than\n requested. At present, the maximum disk size is 1000GB; builds that request\n more than the maximum are rejected with an error."
},
"substitutionOption": {
Expand Down Expand Up @@ -642,7 +641,7 @@
"description": "Google Cloud Storage object containing the source."
},
"generation": {
"type": "string",
"type": "integer",
"description": "Google Cloud Storage generation for the object. If the generation is\n omitted, the latest generation will be used."
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
"google.cloud.firestore.document.v1.written"
],
"product": "Cloud Firestore",
"examples": [
"https://googleapis.github.io/google-cloudevents/testdata/google/events/cloud/firestore/v1/DocumentEventData-complex.json",
"https://googleapis.github.io/google-cloudevents/testdata/google/events/cloud/firestore/v1/DocumentEventData-simple.json"
],
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"value": {
Expand Down Expand Up @@ -96,7 +92,7 @@
"description": "A boolean value."
},
"integerValue": {
"type": "string",
"type": "integer",
"description": "An integer value."
},
"doubleValue": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
"google.cloud.pubsub.topic.v1.messagePublished"
],
"product": "Cloud Pub/Sub",
"examples": [
"https://googleapis.github.io/google-cloudevents/testdata/google/events/cloud/pubsub/v1/MessagePublishedData-binary.json",
"https://googleapis.github.io/google-cloudevents/testdata/google/events/cloud/pubsub/v1/MessagePublishedData-text.json"
],
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"message": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"google.cloud.scheduler.job.v1.executed"
],
"product": "Cloud Scheduler",
"examples": [],
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"customData": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
"google.cloud.storage.object.v1.metadataUpdated"
],
"product": "Cloud Storage",
"examples": [
"https://googleapis.github.io/google-cloudevents/testdata/google/events/cloud/storage/v1/StorageObjectData-simple.json"
],
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"contentEncoding": {
Expand All @@ -32,7 +29,7 @@
"description": "Content-Language of the object data, matching\n [https://tools.ietf.org/html/rfc7231#section-3.1.3.2][RFC 7231 §3.1.3.2]."
},
"metageneration": {
"type": "string",
"type": "integer",
"description": "The version of the metadata for this object at this generation. Used for\n preconditions and for detecting changes in metadata. A metageneration\n number is only meaningful in the context of a particular generation of a\n particular object."
},
"timeDeleted": {
Expand All @@ -45,7 +42,7 @@
"description": "Content-Type of the object data, matching\n [https://tools.ietf.org/html/rfc7231#section-3.1.1.5][RFC 7231 §3.1.1.5].\n If an object is stored without a Content-Type, it is served as\n `application/octet-stream`."
},
"size": {
"type": "string",
"type": "integer",
"description": "Content-Length of the object data in bytes, matching\n [https://tools.ietf.org/html/rfc7230#section-3.3.2][RFC 7230 §3.3.2]."
},
"timeCreated": {
Expand Down Expand Up @@ -120,7 +117,7 @@
"description": "The name of the bucket containing this object."
},
"generation": {
"type": "string",
"type": "integer",
"description": "The content generation of this object. Used for object versioning.\n Attempting to set this field will result in an error."
},
"customerEncryption": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"google.firebase.analytics.log.v1.written"
],
"product": "Google Analytics for Firebase",
"examples": [],
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"userDim": {
Expand All @@ -17,7 +16,7 @@
"description": "The user ID set via the setUserId API."
},
"firstOpenTimestampMicros": {
"type": "string",
"type": "integer",
"description": "The time (in microseconds) at which the user first opened the app."
},
"userProperties": {
Expand All @@ -30,7 +29,7 @@
"description": "Last set value of user property."
},
"setTimestampUsec": {
"type": "string",
"type": "integer",
"description": "UTC client time when user property was last set."
},
"index": {
Expand Down Expand Up @@ -171,7 +170,7 @@
"description": "Monotonically increasing index for each bundle set by SDK."
},
"serverTimestampOffsetMicros": {
"type": "string",
"type": "integer",
"description": "Timestamp offset between collection time and upload time."
}
},
Expand Down Expand Up @@ -220,11 +219,11 @@
"description": "A repeated record of the parameters associated with this event."
},
"timestampMicros": {
"type": "string",
"type": "integer",
"description": "UTC client time when the event happened."
},
"previousTimestampMicros": {
"type": "string",
"type": "integer",
"description": "UTC client time when the previous event happened."
},
"valueInUsd": {
Expand All @@ -250,7 +249,7 @@
"type": "string"
},
"intValue": {
"type": "string"
"type": "integer"
},
"floatValue": {
"type": "number"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"google.firebase.auth.user.v1.deleted"
],
"product": "Firebase Authentication",
"examples": [],
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"uid": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"google.firebase.database.ref.v1.written"
],
"product": "Firebase Realtime Database",
"examples": [],
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"data": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
"google.firebase.remoteconfig.remoteConfig.v1.updated"
],
"product": "Firebase Remote Config",
"examples": [],
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"versionNumber": {
"type": "string",
"type": "integer",
"description": "The version number of the version's corresponding Remote Config template."
},
"updateTime": {
Expand Down Expand Up @@ -65,7 +64,7 @@
"description": "What type of update was made."
},
"rollbackSource": {
"type": "string",
"type": "integer",
"description": "Only present if this version is the result of a rollback, and will be the\n version number of the Remote Config template that was rolled-back to."
}
},
Expand Down
2 changes: 1 addition & 1 deletion tools/proto2jsonschema/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ for proto in $DATA_PROTOS; do
# - Input: proto/ – our CloudEvent protos
# - Input: googlapis/ – common googleapis protos
$PROTOC \
--jsonschema_out=json_fieldnames:$OUT_PROTO_DIR \
--jsonschema_out=disallow_bigints_as_strings:$OUT_PROTO_DIR \
--proto_path=proto/ \
--proto_path=third_party/googleapis \
"$proto"
Expand Down

0 comments on commit 1cdf408

Please sign in to comment.