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

Bugfix for envoyproxy/validate extension #392

Merged
merged 3 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func TestTransform(t *testing.T) {
Type: &validate.FieldRules_String_{
String_: &validate.StringRules{
MinLen: proto.Uint64(1),
NotIn: []string{"invalid"},
},
},
}
Expand All @@ -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"}},
})
}
9 changes: 9 additions & 0 deletions extensions/lyft_validate/alias.go
Original file line number Diff line number Diff line change
@@ -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