@@ -136,13 +136,46 @@ func (addProps AdditionalProperties) MarshalJSON() ([]byte, error)
136
136
func (addProps *AdditionalProperties) UnmarshalJSON(data []byte) error
137
137
UnmarshalJSON sets AdditionalProperties to a copy of data.
138
138
139
- type Callback map[string]*PathItem
139
+ type Callback struct {
140
+ Extensions map[string]interface{} `json:"-" yaml:"-"`
141
+
142
+ // Has unexported fields.
143
+ }
140
144
Callback is specified by OpenAPI/Swagger standard version 3. See
141
145
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callback-object
142
146
143
- func (callback Callback) Validate(ctx context.Context, opts ...ValidationOption) error
147
+ func NewCallback(opts ...NewCallbackOption) *Callback
148
+ NewCallback builds a Callback object with path items in insertion order.
149
+
150
+ func NewCallbackWithCapacity(cap int) *Callback
151
+ NewCallbackWithCapacity builds a Callback object of the given capacity.
152
+
153
+ func (callback Callback) JSONLookup(token string) (interface{}, error)
154
+ JSONLookup implements
155
+ https://github.com/go-openapi/jsonpointer#JSONPointable
156
+
157
+ func (callback *Callback) Len() int
158
+ Len returns the amount of keys in callback excluding callback.Extensions.
159
+
160
+ func (callback *Callback) Map() map[string]*PathItem
161
+ Map returns callback as a 'map'. Note: iteration on Go maps is not ordered.
162
+
163
+ func (callback Callback) MarshalJSON() ([]byte, error)
164
+ MarshalJSON returns the JSON encoding of Callback.
165
+
166
+ func (callback *Callback) Set(key string, value *PathItem)
167
+ Set adds or replaces key 'key' of 'callback' with 'value'. Note: 'callback'
168
+ MUST be non-nil
169
+
170
+ func (callback *Callback) UnmarshalJSON(data []byte) (err error)
171
+ UnmarshalJSON sets Callback to a copy of data.
172
+
173
+ func (callback *Callback) Validate(ctx context.Context, opts ...ValidationOption) error
144
174
Validate returns an error if Callback does not comply with the OpenAPI spec.
145
175
176
+ func (callback *Callback) Value(key string) *PathItem
177
+ Value returns the callback for key or nil
178
+
146
179
type CallbackRef struct {
147
180
Ref string
148
181
Value *Callback
@@ -609,6 +642,27 @@ func (me MultiError) Is(target error) bool
609
642
`errors.Is()` It will also return true if any of the contained errors match
610
643
target
611
644
645
+ type NewCallbackOption func(*Callback)
646
+ NewCallbackOption describes options to NewCallback func
647
+
648
+ func WithCallback(cb string, pathItem *PathItem) NewCallbackOption
649
+ WithCallback adds Callback as an option to NewCallback
650
+
651
+ type NewPathsOption func(*Paths)
652
+ NewPathsOption describes options to NewPaths func
653
+
654
+ func WithPath(path string, pathItem *PathItem) NewPathsOption
655
+ WithPath adds a named path item
656
+
657
+ type NewResponsesOption func(*Responses)
658
+ NewResponsesOption describes options to NewResponses func
659
+
660
+ func WithName(name string, response *Response) NewResponsesOption
661
+ WithName adds a name-keyed Response
662
+
663
+ func WithStatus(status int, responseRef *ResponseRef) NewResponsesOption
664
+ WithStatus adds a status code keyed ResponseRef
665
+
612
666
type OAuthFlow struct {
613
667
Extensions map[string]interface{} `json:"-" yaml:"-"`
614
668
@@ -673,7 +727,7 @@ type Operation struct {
673
727
RequestBody *RequestBodyRef `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`
674
728
675
729
// Responses.
676
- Responses Responses `json:"responses" yaml:"responses"` // Required
730
+ Responses * Responses `json:"responses" yaml:"responses"` // Required
677
731
678
732
// Optional callbacks
679
733
Callbacks Callbacks `json:"callbacks,omitempty" yaml:"callbacks,omitempty"`
@@ -847,11 +901,21 @@ func (pathItem *PathItem) UnmarshalJSON(data []byte) error
847
901
func (pathItem *PathItem) Validate(ctx context.Context, opts ...ValidationOption) error
848
902
Validate returns an error if PathItem does not comply with the OpenAPI spec.
849
903
850
- type Paths map[string]*PathItem
904
+ type Paths struct {
905
+ Extensions map[string]interface{} `json:"-" yaml:"-"`
906
+
907
+ // Has unexported fields.
908
+ }
851
909
Paths is specified by OpenAPI/Swagger standard version 3. See
852
910
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#paths-object
853
911
854
- func (paths Paths) Find(key string) *PathItem
912
+ func NewPaths(opts ...NewPathsOption) *Paths
913
+ NewPaths builds a paths object with path items in insertion order.
914
+
915
+ func NewPathsWithCapacity(cap int) *Paths
916
+ NewPathsWithCapacity builds a paths object of the given capacity.
917
+
918
+ func (paths *Paths) Find(key string) *PathItem
855
919
Find returns a path that matches the key.
856
920
857
921
The method ignores differences in template variable names (except possible
@@ -866,16 +930,39 @@ func (paths Paths) Find(key string) *PathItem
866
930
867
931
would return the correct path item.
868
932
869
- func (paths Paths) InMatchingOrder() []string
933
+ func (paths * Paths) InMatchingOrder() []string
870
934
InMatchingOrder returns paths in the
871
935
order they are matched against URLs. See
872
936
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#paths-object
873
937
When matching URLs, concrete (non-templated) paths would be matched before
874
938
their templated counterparts.
875
939
876
- func (paths Paths) Validate(ctx context.Context, opts ...ValidationOption) error
940
+ func (paths Paths) JSONLookup(token string) (interface{}, error)
941
+ JSONLookup implements
942
+ https://github.com/go-openapi/jsonpointer#JSONPointable
943
+
944
+ func (paths *Paths) Len() int
945
+ Len returns the amount of keys in paths excluding paths.Extensions.
946
+
947
+ func (paths *Paths) Map() map[string]*PathItem
948
+ Map returns paths as a 'map'. Note: iteration on Go maps is not ordered.
949
+
950
+ func (paths Paths) MarshalJSON() ([]byte, error)
951
+ MarshalJSON returns the JSON encoding of Paths.
952
+
953
+ func (paths *Paths) Set(key string, value *PathItem)
954
+ Set adds or replaces key 'key' of 'paths' with 'value'. Note: 'paths' MUST
955
+ be non-nil
956
+
957
+ func (paths *Paths) UnmarshalJSON(data []byte) (err error)
958
+ UnmarshalJSON sets Paths to a copy of data.
959
+
960
+ func (paths *Paths) Validate(ctx context.Context, opts ...ValidationOption) error
877
961
Validate returns an error if Paths does not comply with the OpenAPI spec.
878
962
963
+ func (paths *Paths) Value(key string) *PathItem
964
+ Value returns the paths for key or nil
965
+
879
966
type ReadFromURIFunc func(loader *Loader, url *url.URL) ([]byte, error)
880
967
ReadFromURIFunc defines a function which reads the contents of a resource
881
968
located at a URI.
@@ -1039,28 +1126,58 @@ func (x *ResponseRef) Validate(ctx context.Context, opts ...ValidationOption) er
1039
1126
Validate returns an error if ResponseRef does not comply with the OpenAPI
1040
1127
spec.
1041
1128
1042
- type Responses map[string]*ResponseRef
1129
+ type Responses struct {
1130
+ Extensions map[string]interface{} `json:"-" yaml:"-"`
1131
+
1132
+ // Has unexported fields.
1133
+ }
1043
1134
Responses is specified by OpenAPI/Swagger 3.0 standard. See
1044
1135
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#responses-object
1045
1136
1046
- func NewResponses() Responses
1137
+ func NewResponses(opts ...NewResponsesOption) *Responses
1138
+ NewResponses builds a responses object with response objects in insertion
1139
+ order. Given no arguments, NewResponses returns a valid responses object
1140
+ containing a default match-all reponse.
1047
1141
1048
- func (responses Responses) Default() *ResponseRef
1142
+ func NewResponsesWithCapacity(cap int) *Responses
1143
+ NewResponsesWithCapacity builds a responses object of the given capacity.
1049
1144
1050
- func (responses Responses) Get(status int) *ResponseRef
1051
- Get returns a ResponseRef for the given status If an exact
1145
+ func (responses *Responses) Default() *ResponseRef
1146
+ Default returns the default response
1147
+
1148
+ func (responses Responses) JSONLookup(token string) (interface{}, error)
1149
+ JSONLookup implements
1150
+ https://github.com/go-openapi/jsonpointer#JSONPointable
1151
+
1152
+ func (responses *Responses) Len() int
1153
+ Len returns the amount of keys in responses excluding responses.Extensions.
1154
+
1155
+ func (responses *Responses) Map() map[string]*ResponseRef
1156
+ Map returns responses as a 'map'. Note: iteration on Go maps is not ordered.
1157
+
1158
+ func (responses Responses) MarshalJSON() ([]byte, error)
1159
+ MarshalJSON returns the JSON encoding of Responses.
1160
+
1161
+ func (responses *Responses) Set(key string, value *ResponseRef)
1162
+ Set adds or replaces key 'key' of 'responses' with 'value'. Note:
1163
+ 'responses' MUST be non-nil
1164
+
1165
+ func (responses *Responses) Status(status int) *ResponseRef
1166
+ Status returns a ResponseRef for the given status If an exact
1052
1167
match isn't initially found a patterned field is checked using
1053
1168
the first digit to determine the range (eg: 201 to 2XX) See
1054
1169
https://spec.openapis.org/oas/v3.0.3#patterned-fields-0
1055
1170
1056
- func (responses Responses) JSONLookup(token string) (interface{}, error)
1057
- JSONLookup implements
1058
- https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
1171
+ func (responses *Responses) UnmarshalJSON(data []byte) (err error)
1172
+ UnmarshalJSON sets Responses to a copy of data.
1059
1173
1060
- func (responses Responses) Validate(ctx context.Context, opts ...ValidationOption) error
1174
+ func (responses * Responses) Validate(ctx context.Context, opts ...ValidationOption) error
1061
1175
Validate returns an error if Responses does not comply with the OpenAPI
1062
1176
spec.
1063
1177
1178
+ func (responses *Responses) Value(key string) *ResponseRef
1179
+ Value returns the responses for key or nil
1180
+
1064
1181
type Schema struct {
1065
1182
Extensions map[string]interface{} `json:"-" yaml:"-"`
1066
1183
@@ -1519,7 +1636,7 @@ type T struct {
1519
1636
OpenAPI string `json:"openapi" yaml:"openapi"` // Required
1520
1637
Components *Components `json:"components,omitempty" yaml:"components,omitempty"`
1521
1638
Info *Info `json:"info" yaml:"info"` // Required
1522
- Paths Paths `json:"paths" yaml:"paths"` // Required
1639
+ Paths * Paths `json:"paths" yaml:"paths"` // Required
1523
1640
Security SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"`
1524
1641
Servers Servers `json:"servers,omitempty" yaml:"servers,omitempty"`
1525
1642
Tags Tags `json:"tags,omitempty" yaml:"tags,omitempty"`
0 commit comments