/
xml.go
34 lines (27 loc) · 1.06 KB
/
xml.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package openapi3
import (
"context"
"github.com/getkin/kin-openapi/jsoninfo"
)
// XML is specified by OpenAPI/Swagger standard version 3.
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#xmlObject
type XML struct {
ExtensionProps `json:"-" yaml:"-"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty"`
Attribute bool `json:"attribute,omitempty" yaml:"attribute,omitempty"`
Wrapped bool `json:"wrapped,omitempty" yaml:"wrapped,omitempty"`
}
// MarshalJSON returns the JSON encoding of XML.
func (xml *XML) MarshalJSON() ([]byte, error) {
return jsoninfo.MarshalStrictStruct(xml)
}
// UnmarshalJSON sets XML to a copy of data.
func (xml *XML) UnmarshalJSON(data []byte) error {
return jsoninfo.UnmarshalStrictStruct(data, xml)
}
// Validate returns an error if XML does not comply with the OpenAPI spec.
func (xml *XML) Validate(ctx context.Context) error {
return nil // TODO
}