Skip to content

Commit 6d6f1ef

Browse files
authored
Add extensions in missing resources (#306)
1 parent b2761ee commit 6d6f1ef

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

openapi2/openapi2.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,20 @@ func (response *Response) UnmarshalJSON(data []byte) error {
237237
}
238238

239239
type Header struct {
240+
openapi3.ExtensionProps
240241
Ref string `json:"$ref,omitempty"`
241242
Description string `json:"description,omitempty"`
242243
Type string `json:"type,omitempty"`
243244
}
244245

246+
func (header *Header) MarshalJSON() ([]byte, error) {
247+
return jsoninfo.MarshalStrictStruct(header)
248+
}
249+
250+
func (header *Header) UnmarshalJSON(data []byte) error {
251+
return jsoninfo.UnmarshalStrictStruct(data, header)
252+
}
253+
245254
type SecurityRequirements []map[string][]string
246255

247256
type SecurityScheme struct {

openapi3/server.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ type Server struct {
4545
Variables map[string]*ServerVariable `json:"variables,omitempty" yaml:"variables,omitempty"`
4646
}
4747

48-
func (value *Server) MarshalJSON() ([]byte, error) {
49-
return jsoninfo.MarshalStrictStruct(value)
48+
func (server *Server) MarshalJSON() ([]byte, error) {
49+
return jsoninfo.MarshalStrictStruct(server)
5050
}
5151

52-
func (value *Server) UnmarshalJSON(data []byte) error {
53-
return jsoninfo.UnmarshalStrictStruct(data, value)
52+
func (server *Server) UnmarshalJSON(data []byte) error {
53+
return jsoninfo.UnmarshalStrictStruct(data, server)
5454
}
5555

5656
func (server Server) ParameterNames() ([]string, error) {
@@ -138,11 +138,20 @@ func (server *Server) Validate(c context.Context) (err error) {
138138

139139
// ServerVariable is specified by OpenAPI/Swagger standard version 3.0.
140140
type ServerVariable struct {
141+
ExtensionProps
141142
Enum []interface{} `json:"enum,omitempty" yaml:"enum,omitempty"`
142143
Default interface{} `json:"default,omitempty" yaml:"default,omitempty"`
143144
Description string `json:"description,omitempty" yaml:"description,omitempty"`
144145
}
145146

147+
func (serverVariable *ServerVariable) MarshalJSON() ([]byte, error) {
148+
return jsoninfo.MarshalStrictStruct(serverVariable)
149+
}
150+
151+
func (serverVariable *ServerVariable) UnmarshalJSON(data []byte) error {
152+
return jsoninfo.UnmarshalStrictStruct(data, serverVariable)
153+
}
154+
146155
func (serverVariable *ServerVariable) Validate(c context.Context) error {
147156
switch serverVariable.Default.(type) {
148157
case float64, string:

openapi3/tag.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package openapi3
22

3+
import "github.com/getkin/kin-openapi/jsoninfo"
4+
35
// Tags is specified by OpenAPI/Swagger 3.0 standard.
46
type Tags []*Tag
57

@@ -14,7 +16,16 @@ func (tags Tags) Get(name string) *Tag {
1416

1517
// Tag is specified by OpenAPI/Swagger 3.0 standard.
1618
type Tag struct {
19+
ExtensionProps
1720
Name string `json:"name,omitempty" yaml:"name,omitempty"`
1821
Description string `json:"description,omitempty" yaml:"description,omitempty"`
1922
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
2023
}
24+
25+
func (t *Tag) MarshalJSON() ([]byte, error) {
26+
return jsoninfo.MarshalStrictStruct(t)
27+
}
28+
29+
func (t *Tag) UnmarshalJSON(data []byte) error {
30+
return jsoninfo.UnmarshalStrictStruct(data, t)
31+
}

0 commit comments

Comments
 (0)