File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package openapi
3
3
import (
4
4
"errors"
5
5
"strings"
6
+
7
+ "github.com/MarkRosemaker/errpath"
6
8
)
7
9
8
10
// The `Link object` represents a possible design-time link for a response.
@@ -52,6 +54,12 @@ func (l *Link) Validate() error {
52
54
53
55
l .Description = strings .TrimSpace (l .Description )
54
56
57
+ if l .Server != nil {
58
+ if err := l .Server .Validate (); err != nil {
59
+ return & errpath.ErrField {Field : "server" , Err : err }
60
+ }
61
+ }
62
+
55
63
return validateExtensions (l .Extensions )
56
64
}
57
65
Original file line number Diff line number Diff line change @@ -21,6 +21,13 @@ func TestLinks_Validate_Error(t *testing.T) {
21
21
openapi.Links {" " : {Value : & openapi.Link {}}},
22
22
`[" "] (" ") is invalid: must match the regular expression "^[a-zA-Z0-9\\.\\-_]+$"` ,
23
23
},
24
+ {
25
+ openapi.Links {"foo" : {Value : & openapi.Link {
26
+ OperationID : "myOperation" ,
27
+ Server : & openapi.Server {},
28
+ }}},
29
+ `foo.server.url is required` ,
30
+ },
24
31
} {
25
32
t .Run (tc .err , func (t * testing.T ) {
26
33
if err := tc .ls .Validate (); err == nil || err .Error () != tc .err {
You can’t perform that action at this time.
0 commit comments