This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert google Int64Value to strings (#131)
* Add support to convert google Int64Value wrappers to string type. * Add files and test for disallowing strings and allow null values. * Add test cases for disallowing big ints as strings. Co-authored-by: Ian Van Den Heuvel <ivandenheuvel@auvik.com>
- Loading branch information
1 parent
6f71afe
commit c6dba84
Showing
16 changed files
with
312 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package testdata | ||
|
||
const GoogleInt64Value = `{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$ref": "#/definitions/GoogleInt64Value", | ||
"definitions": { | ||
"GoogleInt64Value": { | ||
"properties": { | ||
"big_number": { | ||
"additionalProperties": true, | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"type": "object", | ||
"title": "Google Int 64 Value" | ||
} | ||
} | ||
}` | ||
|
||
const GoogleInt64ValueFail = `{"big_number": 12345}` | ||
|
||
const GoogleInt64ValuePass = `{"big_number": "12345"}` |
38 changes: 38 additions & 0 deletions
38
internal/converter/testdata/google_int64_value_allow_null.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package testdata | ||
|
||
const GoogleInt64ValueAllowNull = `{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$ref": "#/definitions/GoogleInt64ValueAllowNull", | ||
"definitions": { | ||
"GoogleInt64ValueAllowNull": { | ||
"properties": { | ||
"big_number": { | ||
"oneOf": [ | ||
{ | ||
"type": "null" | ||
}, | ||
{ | ||
"type": "string" | ||
} | ||
], | ||
"title": "Int 64 Value", | ||
"description": "Wrapper message for ` + "`int64`" + `. The JSON representation for ` + "`Int64Value`" + ` is JSON string." | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"oneOf": [ | ||
{ | ||
"type": "null" | ||
}, | ||
{ | ||
"type": "object" | ||
} | ||
], | ||
"title": "Google Int 64 Value Allow Null" | ||
} | ||
} | ||
}` | ||
|
||
const GoogleInt64ValueAllowNullFail = `{"big_number": 12345}` | ||
|
||
const GoogleInt64ValueAllowNullPass = `{"big_number": null}` |
23 changes: 23 additions & 0 deletions
23
internal/converter/testdata/google_int64_value_disallow_string.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package testdata | ||
|
||
const GoogleInt64ValueDisallowString = `{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$ref": "#/definitions/GoogleInt64ValueDisallowString", | ||
"definitions": { | ||
"GoogleInt64ValueDisallowString": { | ||
"properties": { | ||
"big_number": { | ||
"additionalProperties": true, | ||
"type": "integer" | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"type": "object", | ||
"title": "Google Int 64 Value Disallow String" | ||
} | ||
} | ||
}` | ||
|
||
const GoogleInt64ValueDisallowStringFail = `{"big_number": "12345"}` | ||
|
||
const GoogleInt64ValueDisallowStringPass = `{"big_number": 12345}` |
38 changes: 38 additions & 0 deletions
38
internal/converter/testdata/google_int64_value_disallow_string_allow_null.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package testdata | ||
|
||
const GoogleInt64ValueDisallowStringAllowNull = `{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$ref": "#/definitions/GoogleInt64ValueDisallowStringAllowNull", | ||
"definitions": { | ||
"GoogleInt64ValueDisallowStringAllowNull": { | ||
"properties": { | ||
"big_number": { | ||
"oneOf": [ | ||
{ | ||
"type": "null" | ||
}, | ||
{ | ||
"type": "integer" | ||
} | ||
], | ||
"title": "Int 64 Value", | ||
"description": "Wrapper message for ` + "`int64`" + `. The JSON representation for ` + "`Int64Value`" + ` is JSON string." | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"oneOf": [ | ||
{ | ||
"type": "null" | ||
}, | ||
{ | ||
"type": "object" | ||
} | ||
], | ||
"title": "Google Int 64 Value Disallow String Allow Null" | ||
} | ||
} | ||
}` | ||
|
||
const GoogleInt64ValueDisallowStringAllowNullFail = `{"big_number": "12345"}` | ||
|
||
const GoogleInt64ValueDisallowStringAllowNullPass = `{"big_number": null}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
syntax = "proto3"; | ||
package samples; | ||
|
||
import "google/protobuf/wrappers.proto"; | ||
|
||
message GoogleInt64Value { | ||
google.protobuf.Int64Value big_number = 1; | ||
} |
8 changes: 8 additions & 0 deletions
8
internal/converter/testdata/proto/GoogleInt64ValueAllowNull.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
syntax = "proto3"; | ||
package samples; | ||
|
||
import "google/protobuf/wrappers.proto"; | ||
|
||
message GoogleInt64ValueAllowNull { | ||
google.protobuf.Int64Value big_number = 1; | ||
} |
8 changes: 8 additions & 0 deletions
8
internal/converter/testdata/proto/GoogleInt64ValueDisallowString.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
syntax = "proto3"; | ||
package samples; | ||
|
||
import "google/protobuf/wrappers.proto"; | ||
|
||
message GoogleInt64ValueDisallowString { | ||
google.protobuf.Int64Value big_number = 1; | ||
} |
8 changes: 8 additions & 0 deletions
8
internal/converter/testdata/proto/GoogleInt64ValueDisallowStringAllowNull.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
syntax = "proto3"; | ||
package samples; | ||
|
||
import "google/protobuf/wrappers.proto"; | ||
|
||
message GoogleInt64ValueDisallowStringAllowNull { | ||
google.protobuf.Int64Value big_number = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$ref": "#/definitions/GoogleInt64Value", | ||
"definitions": { | ||
"GoogleInt64Value": { | ||
"properties": { | ||
"big_number": { | ||
"additionalProperties": true, | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"type": "object", | ||
"title": "Google Int 64 Value" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$ref": "#/definitions/GoogleInt64ValueAllowNull", | ||
"definitions": { | ||
"GoogleInt64ValueAllowNull": { | ||
"properties": { | ||
"big_number": { | ||
"oneOf": [ | ||
{ | ||
"type": "null" | ||
}, | ||
{ | ||
"type": "string" | ||
} | ||
], | ||
"title": "Int 64 Value", | ||
"description": "Wrapper message for `int64`. The JSON representation for `Int64Value` is JSON string." | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"oneOf": [ | ||
{ | ||
"type": "null" | ||
}, | ||
{ | ||
"type": "object" | ||
} | ||
], | ||
"title": "Google Int 64 Value Allow Null" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$ref": "#/definitions/GoogleInt64ValueDisallowString", | ||
"definitions": { | ||
"GoogleInt64ValueDisallowString": { | ||
"properties": { | ||
"big_number": { | ||
"additionalProperties": true, | ||
"type": "integer" | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"type": "object", | ||
"title": "Google Int 64 Value Disallow String" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$ref": "#/definitions/GoogleInt64ValueDisallowStringAllowNull", | ||
"definitions": { | ||
"GoogleInt64ValueDisallowStringAllowNull": { | ||
"properties": { | ||
"big_number": { | ||
"oneOf": [ | ||
{ | ||
"type": "null" | ||
}, | ||
{ | ||
"type": "integer" | ||
} | ||
], | ||
"title": "Int 64 Value", | ||
"description": "Wrapper message for `int64`. The JSON representation for `Int64Value` is JSON string." | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"oneOf": [ | ||
{ | ||
"type": "null" | ||
}, | ||
{ | ||
"type": "object" | ||
} | ||
], | ||
"title": "Google Int 64 Value Disallow String Allow Null" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters