Skip to content

Commit 65a5e8d

Browse files
authored
fixes #22
1 parent 0428f18 commit 65a5e8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+261
-57
lines changed

callbacks.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ func (c Callbacks) MarshalYAML() (interface{}, error) {
138138

139139
// UnmarshalYAML implements yaml.Unmarshaler
140140
func (c *Callbacks) UnmarshalYAML(value *yaml.Node) error {
141-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
141+
v, err := yaml.Marshal(value)
142+
if err != nil {
143+
return err
144+
}
145+
j, err := transcode.JSONFromYAML(v)
142146
if err != nil {
143147
return err
144148
}

component.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ func (c *Component[T]) MarshalYAML() (interface{}, error) {
177177

178178
// UnmarshalYAML implements yaml.Unmarshaler
179179
func (c *Component[T]) UnmarshalYAML(value *yaml.Node) error {
180-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
180+
v, err := yaml.Marshal(value)
181+
if err != nil {
182+
return err
183+
}
184+
j, err := transcode.JSONFromYAML(v)
181185
if err != nil {
182186
return err
183187
}

component_map.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ func (cm *ComponentMap[T]) MarshalYAML() (interface{}, error) {
164164

165165
// UnmarshalYAML implements yaml.Unmarshaler
166166
func (cm *ComponentMap[T]) UnmarshalYAML(value *yaml.Node) error {
167-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
167+
v, err := yaml.Marshal(value)
168+
if err != nil {
169+
return err
170+
}
171+
j, err := transcode.JSONFromYAML(v)
168172
if err != nil {
169173
return err
170174
}

component_slice.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ func (cs *ComponentSlice[T]) MarshalYAML() (interface{}, error) {
125125

126126
// UnmarshalYAML implements yaml.Unmarshaler
127127
func (cs *ComponentSlice[T]) UnmarshalYAML(value *yaml.Node) error {
128-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
128+
v, err := yaml.Marshal(value)
129+
if err != nil {
130+
return err
131+
}
132+
j, err := transcode.JSONFromYAML(v)
129133
if err != nil {
130134
return err
131135
}

components.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,11 @@ func (c Components) MarshalYAML() (interface{}, error) {
278278

279279
// UnmarshalYAML implements yaml.Unmarshaler
280280
func (c *Components) UnmarshalYAML(value *yaml.Node) error {
281-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
281+
v, err := yaml.Marshal(value)
282+
if err != nil {
283+
return err
284+
}
285+
j, err := transcode.JSONFromYAML(v)
282286
if err != nil {
283287
return err
284288
}

contact.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ func (c Contact) MarshalYAML() (interface{}, error) {
8383

8484
// UnmarshalYAML implements yaml.Unmarshaler
8585
func (c *Contact) UnmarshalYAML(value *yaml.Node) error {
86-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
86+
v, err := yaml.Marshal(value)
87+
if err != nil {
88+
return err
89+
}
90+
j, err := transcode.JSONFromYAML(v)
8791
if err != nil {
8892
return err
8993
}

discriminator.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ func (d Discriminator) MarshalYAML() (interface{}, error) {
8585

8686
// UnmarshalYAML implements yaml.Unmarshaler
8787
func (d *Discriminator) UnmarshalYAML(value *yaml.Node) error {
88-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
88+
v, err := yaml.Marshal(value)
89+
if err != nil {
90+
return err
91+
}
92+
j, err := transcode.JSONFromYAML(v)
8993
if err != nil {
9094
return err
9195
}

document.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ func (d Document) MarshalYAML() (interface{}, error) {
190190

191191
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
192192
func (d *Document) UnmarshalYAML(value *yaml.Node) error {
193-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
193+
v, err := yaml.Marshal(value)
194+
if err != nil {
195+
return err
196+
}
197+
j, err := transcode.JSONFromYAML(v)
194198
if err != nil {
195199
return err
196200
}

encoding.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ func (e Encoding) MarshalYAML() (interface{}, error) {
152152

153153
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
154154
func (e *Encoding) UnmarshalYAML(value *yaml.Node) error {
155-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
155+
v, err := yaml.Marshal(value)
156+
if err != nil {
157+
return err
158+
}
159+
j, err := transcode.JSONFromYAML(v)
156160
if err != nil {
157161
return err
158162
}

example.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ func (e Example) MarshalYAML() (interface{}, error) {
8787

8888
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
8989
func (e *Example) UnmarshalYAML(value *yaml.Node) error {
90-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
90+
v, err := yaml.Marshal(value)
91+
if err != nil {
92+
return err
93+
}
94+
j, err := transcode.JSONFromYAML(v)
9195
if err != nil {
9296
return err
9397
}

example_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package openapi_test
1+
package openapi
22

33
// import (
44
// "encoding/json"

external_docs.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ func (ed ExternalDocs) MarshalYAML() (interface{}, error) {
9898

9999
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
100100
func (ed *ExternalDocs) UnmarshalYAML(value *yaml.Node) error {
101-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
101+
v, err := yaml.Marshal(value)
102+
if err != nil {
103+
return err
104+
}
105+
j, err := transcode.JSONFromYAML(v)
102106
if err != nil {
103107
return err
104108
}

header.go

+3-17
Original file line numberDiff line numberDiff line change
@@ -151,29 +151,15 @@ func (h Header) MarshalYAML() (interface{}, error) {
151151

152152
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
153153
func (h *Header) UnmarshalYAML(value *yaml.Node) error {
154-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
154+
v, err := yaml.Marshal(value)
155155
if err != nil {
156156
return err
157157
}
158-
return json.Unmarshal(j, h)
159-
}
160-
161-
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Marshaler interface
162-
func (s Schema) MarshalYAML() (interface{}, error) {
163-
j, err := s.MarshalJSON()
164-
if err != nil {
165-
return nil, err
166-
}
167-
return transcode.YAMLFromJSON(j)
168-
}
169-
170-
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
171-
func (s *Schema) UnmarshalYAML(value *yaml.Node) error {
172-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
158+
j, err := transcode.JSONFromYAML(v)
173159
if err != nil {
174160
return err
175161
}
176-
return json.Unmarshal(j, s)
162+
return json.Unmarshal(j, h)
177163
}
178164

179165
func (h *Header) setLocation(loc Location) error {

info.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ func (i Info) MarshalYAML() (interface{}, error) {
155155

156156
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
157157
func (i *Info) UnmarshalYAML(value *yaml.Node) error {
158-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
158+
v, err := yaml.Marshal(value)
159+
if err != nil {
160+
return err
161+
}
162+
j, err := transcode.JSONFromYAML(v)
159163
if err != nil {
160164
return err
161165
}

license.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ func (l License) MarshalYAML() (interface{}, error) {
8383

8484
// UnmarshalYAML implements yaml.Unmarshaler
8585
func (l *License) UnmarshalYAML(value *yaml.Node) error {
86-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
86+
v, err := yaml.Marshal(value)
87+
if err != nil {
88+
return err
89+
}
90+
j, err := transcode.JSONFromYAML(v)
8791
if err != nil {
8892
return err
8993
}

link.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ func (l Link) MarshalYAML() (interface{}, error) {
133133

134134
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
135135
func (l *Link) UnmarshalYAML(value *yaml.Node) error {
136-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
136+
v, err := yaml.Marshal(value)
137+
if err != nil {
138+
return err
139+
}
140+
j, err := transcode.JSONFromYAML(v)
137141
if err != nil {
138142
return err
139143
}

media_type.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ func (mt MediaType) MarshalYAML() (interface{}, error) {
149149

150150
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
151151
func (mt *MediaType) UnmarshalYAML(value *yaml.Node) error {
152-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
152+
v, err := yaml.Marshal(value)
153+
if err != nil {
154+
return err
155+
}
156+
j, err := transcode.JSONFromYAML(v)
153157
if err != nil {
154158
return err
155159
}

oauth_flow.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ func (o OAuthFlow) MarshalYAML() (interface{}, error) {
128128

129129
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
130130
func (o *OAuthFlow) UnmarshalYAML(value *yaml.Node) error {
131-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
131+
v, err := yaml.Marshal(value)
132+
if err != nil {
133+
return err
134+
}
135+
j, err := transcode.JSONFromYAML(v)
132136
if err != nil {
133137
return err
134138
}
@@ -292,7 +296,11 @@ func (f OAuthFlows) MarshalYAML() (interface{}, error) {
292296

293297
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
294298
func (f *OAuthFlows) UnmarshalYAML(value *yaml.Node) error {
295-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
299+
v, err := yaml.Marshal(value)
300+
if err != nil {
301+
return err
302+
}
303+
j, err := transcode.JSONFromYAML(v)
296304
if err != nil {
297305
return err
298306
}

obj_map.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ func (om ObjMap[T]) MarshalYAML() (interface{}, error) {
163163

164164
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
165165
func (om *ObjMap[T]) UnmarshalYAML(value *yaml.Node) error {
166-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
166+
v, err := yaml.Marshal(value)
167+
if err != nil {
168+
return err
169+
}
170+
j, err := transcode.JSONFromYAML(v)
167171
if err != nil {
168172
return err
169173
}

obj_slice.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ func (os ObjSlice[T]) MarshalYAML() (interface{}, error) {
9595

9696
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
9797
func (os *ObjSlice[T]) UnmarshalYAML(value *yaml.Node) error {
98-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
98+
v, err := yaml.Marshal(value)
99+
if err != nil {
100+
return err
101+
}
102+
j, err := transcode.JSONFromYAML(v)
99103
if err != nil {
100104
return err
101105
}

operation.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,11 @@ func (o Operation) MarshalYAML() (interface{}, error) {
266266

267267
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
268268
func (o *Operation) UnmarshalYAML(value *yaml.Node) error {
269-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
269+
v, err := yaml.Marshal(value)
270+
if err != nil {
271+
return err
272+
}
273+
j, err := transcode.JSONFromYAML(v)
270274
if err != nil {
271275
return err
272276
}

operation_ref.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ func (or OperationRef) MarshalYAML() (interface{}, error) {
9898

9999
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
100100
func (or *OperationRef) UnmarshalYAML(value *yaml.Node) error {
101-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
101+
v, err := yaml.Marshal(value)
102+
if err != nil {
103+
return err
104+
}
105+
j, err := transcode.JSONFromYAML(v)
102106
if err != nil {
103107
return err
104108
}

parameter.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,11 @@ func (p Parameter) MarshalYAML() (interface{}, error) {
330330

331331
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
332332
func (p *Parameter) UnmarshalYAML(value *yaml.Node) error {
333-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
333+
v, err := yaml.Marshal(value)
334+
if err != nil {
335+
return err
336+
}
337+
j, err := transcode.JSONFromYAML(v)
334338
if err != nil {
335339
return err
336340
}

path_item.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ func (p PathItem) MarshalYAML() (interface{}, error) {
214214

215215
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
216216
func (p *PathItem) UnmarshalYAML(value *yaml.Node) error {
217-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
217+
v, err := yaml.Marshal(value)
218+
if err != nil {
219+
return err
220+
}
221+
j, err := transcode.JSONFromYAML(v)
218222
if err != nil {
219223
return err
220224
}

paths.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ func (p Paths) MarshalYAML() (interface{}, error) {
128128

129129
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
130130
func (p *Paths) UnmarshalYAML(value *yaml.Node) error {
131-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
131+
v, err := yaml.Marshal(value)
132+
if err != nil {
133+
return err
134+
}
135+
j, err := transcode.JSONFromYAML(v)
132136
if err != nil {
133137
return err
134138
}

reference.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ func (r Reference[T]) MarshalYAML() (interface{}, error) {
159159

160160
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
161161
func (r *Reference[T]) UnmarshalYAML(value *yaml.Node) error {
162-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
162+
v, err := yaml.Marshal(value)
163+
if err != nil {
164+
return err
165+
}
166+
j, err := transcode.JSONFromYAML(v)
163167
if err != nil {
164168
return err
165169
}

request_body.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ func (rb RequestBody) MarshalYAML() (interface{}, error) {
111111

112112
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
113113
func (rb *RequestBody) UnmarshalYAML(value *yaml.Node) error {
114-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
114+
v, err := yaml.Marshal(value)
115+
if err != nil {
116+
return err
117+
}
118+
j, err := transcode.JSONFromYAML(v)
115119
if err != nil {
116120
return err
117121
}

response.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ func (r Response) MarshalYAML() (interface{}, error) {
118118

119119
// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
120120
func (r *Response) UnmarshalYAML(value *yaml.Node) error {
121-
j, err := transcode.YAMLFromJSON([]byte(value.Value))
121+
v, err := yaml.Marshal(value)
122+
if err != nil {
123+
return err
124+
}
125+
j, err := transcode.JSONFromYAML(v)
122126
if err != nil {
123127
return err
124128
}

0 commit comments

Comments
 (0)