Skip to content

Commit

Permalink
fixes #22
Browse files Browse the repository at this point in the history
  • Loading branch information
chanced authored Sep 28, 2022
1 parent 0428f18 commit 65a5e8d
Show file tree
Hide file tree
Showing 41 changed files with 261 additions and 57 deletions.
6 changes: 5 additions & 1 deletion callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ func (c Callbacks) MarshalYAML() (interface{}, error) {

// UnmarshalYAML implements yaml.Unmarshaler
func (c *Callbacks) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion component.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ func (c *Component[T]) MarshalYAML() (interface{}, error) {

// UnmarshalYAML implements yaml.Unmarshaler
func (c *Component[T]) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion component_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ func (cm *ComponentMap[T]) MarshalYAML() (interface{}, error) {

// UnmarshalYAML implements yaml.Unmarshaler
func (cm *ComponentMap[T]) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion component_slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ func (cs *ComponentSlice[T]) MarshalYAML() (interface{}, error) {

// UnmarshalYAML implements yaml.Unmarshaler
func (cs *ComponentSlice[T]) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion components.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,11 @@ func (c Components) MarshalYAML() (interface{}, error) {

// UnmarshalYAML implements yaml.Unmarshaler
func (c *Components) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ func (c Contact) MarshalYAML() (interface{}, error) {

// UnmarshalYAML implements yaml.Unmarshaler
func (c *Contact) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion discriminator.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ func (d Discriminator) MarshalYAML() (interface{}, error) {

// UnmarshalYAML implements yaml.Unmarshaler
func (d *Discriminator) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion document.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ func (d Document) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (d *Document) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ func (e Encoding) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (e *Encoding) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion example.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ func (e Example) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (e *Example) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package openapi_test
package openapi

// import (
// "encoding/json"
Expand Down
6 changes: 5 additions & 1 deletion external_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ func (ed ExternalDocs) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (ed *ExternalDocs) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
20 changes: 3 additions & 17 deletions header.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,29 +151,15 @@ func (h Header) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (h *Header) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
return json.Unmarshal(j, h)
}

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Marshaler interface
func (s Schema) MarshalYAML() (interface{}, error) {
j, err := s.MarshalJSON()
if err != nil {
return nil, err
}
return transcode.YAMLFromJSON(j)
}

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (s *Schema) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
return json.Unmarshal(j, s)
return json.Unmarshal(j, h)
}

func (h *Header) setLocation(loc Location) error {
Expand Down
6 changes: 5 additions & 1 deletion info.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ func (i Info) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (i *Info) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion license.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ func (l License) MarshalYAML() (interface{}, error) {

// UnmarshalYAML implements yaml.Unmarshaler
func (l *License) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion link.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ func (l Link) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (l *Link) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion media_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ func (mt MediaType) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (mt *MediaType) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
12 changes: 10 additions & 2 deletions oauth_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ func (o OAuthFlow) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (o *OAuthFlow) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down Expand Up @@ -292,7 +296,11 @@ func (f OAuthFlows) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (f *OAuthFlows) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion obj_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ func (om ObjMap[T]) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (om *ObjMap[T]) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion obj_slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ func (os ObjSlice[T]) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (os *ObjSlice[T]) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ func (o Operation) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (o *Operation) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion operation_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ func (or OperationRef) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (or *OperationRef) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,11 @@ func (p Parameter) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (p *Parameter) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion path_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ func (p PathItem) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (p *PathItem) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ func (p Paths) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (p *Paths) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ func (r Reference[T]) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (r *Reference[T]) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion request_body.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ func (rb RequestBody) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (rb *RequestBody) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion response.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ func (r Response) MarshalYAML() (interface{}, error) {

// UnmarshalYAML satisfies gopkg.in/yaml.v3 Unmarshaler interface
func (r *Response) UnmarshalYAML(value *yaml.Node) error {
j, err := transcode.YAMLFromJSON([]byte(value.Value))
v, err := yaml.Marshal(value)
if err != nil {
return err
}
j, err := transcode.JSONFromYAML(v)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 65a5e8d

Please sign in to comment.