-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
improve WKT handling in gateway and openapi output #404
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ package runtime | |
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/gogo/protobuf/jsonpb" | ||
"github.com/golang/protobuf/ptypes/duration" | ||
"github.com/golang/protobuf/ptypes/timestamp" | ||
) | ||
|
||
// String just returns the given string. | ||
|
@@ -56,3 +60,17 @@ func Uint32(val string) (uint32, error) { | |
} | ||
return uint32(i), nil | ||
} | ||
|
||
// Timestamp converts the given RFC3339 formatted string into a timestamp.Timestamp. | ||
func Timestamp(val string) (*timestamp.Timestamp, error) { | ||
var r *timestamp.Timestamp | ||
err := jsonpb.UnmarshalString(val, r) | ||
return r, err | ||
} | ||
|
||
// Duration converts the given string into a timestamp.Duration. | ||
func Duration(val string) (*duration.Duration, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a couple of simple tests to validate this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was considering that but figured this code was well-tested in jsonpb There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've been thinking on this for a bit. I think you're just exposing helper methods against jsonpb. That should mean they are well tested. If these were to become more complex then I would want tests but they are just so imple I think we should leave it. |
||
var r *duration.Duration | ||
err := jsonpb.UnmarshalString(val, r) | ||
return r, err | ||
} |
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.
When would these functions be called?
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.
these are dropped in as 'runtime.Timestamp' calls via
ConvertFuncExpr