diff --git a/CHANGELOG.md b/CHANGELOG.md index 49f8c88b..b3d04cfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed * Stripped unnecessary whitespace from markdown templates +* Renamed `lyft_validate` extension to `envoyproxy_validate` +* Fixed `envoyproxy_validate` rules with slice values such as `in` and `not_in` ## [v1.3.1](https://github.com/pseudomuto/protoc-gen-doc/compare/v1.3.0...v1.3.1) diff --git a/extensions/lyft_validate/lyft_validate.go b/extensions/envoyproxy_validate/envoyproxy_validate.go similarity index 99% rename from extensions/lyft_validate/lyft_validate.go rename to extensions/envoyproxy_validate/envoyproxy_validate.go index c5b83e57..70941f65 100644 --- a/extensions/lyft_validate/lyft_validate.go +++ b/extensions/envoyproxy_validate/envoyproxy_validate.go @@ -73,6 +73,7 @@ func flattenRules(prefix string, vv reflect.Value) (rules []ValidateRule) { if vv.Len() == 0 { return nil } + fallthrough default: rules = append(rules, ValidateRule{Name: prefix, Value: vv.Interface()}) } diff --git a/extensions/lyft_validate/lyft_validate_test.go b/extensions/envoyproxy_validate/envoyproxy_validate_test.go similarity index 89% rename from extensions/lyft_validate/lyft_validate_test.go rename to extensions/envoyproxy_validate/envoyproxy_validate_test.go index 3d5f3f10..7c6cae87 100644 --- a/extensions/lyft_validate/lyft_validate_test.go +++ b/extensions/envoyproxy_validate/envoyproxy_validate_test.go @@ -15,6 +15,7 @@ func TestTransform(t *testing.T) { Type: &validate.FieldRules_String_{ String_: &validate.StringRules{ MinLen: proto.Uint64(1), + NotIn: []string{"invalid"}, }, }, } @@ -25,5 +26,6 @@ func TestTransform(t *testing.T) { rules := transformed["validate.rules"].(ValidateExtension).Rules() require.Equal(t, rules, []ValidateRule{ {Name: "string.min_len", Value: uint64(1)}, + {Name: "string.not_in", Value: []string{"invalid"}}, }) } diff --git a/extensions/lyft_validate/alias.go b/extensions/lyft_validate/alias.go new file mode 100644 index 00000000..985a0cf9 --- /dev/null +++ b/extensions/lyft_validate/alias.go @@ -0,0 +1,9 @@ +package extensions + +import evp "github.com/pseudomuto/protoc-gen-doc/extensions/envoyproxy_validate" + +// ValidateRule represents a single validator rule from the (validate.rules) method option extension. +type ValidateRule = evp.ValidateRule + +// ValidateExtension contains the rules set by the (validate.rules) method option extension. +type ValidateExtension = evp.ValidateExtension