forked from getkin/kin-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscriminator.go
31 lines (24 loc) · 1023 Bytes
/
discriminator.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
package openapi3
import (
"context"
"github.com/getkin/kin-openapi/jsoninfo"
)
// Discriminator is specified by OpenAPI/Swagger standard version 3.
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#discriminatorObject
type Discriminator struct {
ExtensionProps `json:"-" yaml:"-"`
PropertyName string `json:"propertyName" yaml:"propertyName"`
Mapping map[string]string `json:"mapping,omitempty" yaml:"mapping,omitempty"`
}
// MarshalJSON returns the JSON encoding of Discriminator.
func (discriminator *Discriminator) MarshalJSON() ([]byte, error) {
return jsoninfo.MarshalStrictStruct(discriminator)
}
// UnmarshalJSON sets Discriminator to a copy of data.
func (discriminator *Discriminator) UnmarshalJSON(data []byte) error {
return jsoninfo.UnmarshalStrictStruct(data, discriminator)
}
// Validate returns an error if Discriminator does not comply with the OpenAPI spec.
func (discriminator *Discriminator) Validate(ctx context.Context) error {
return nil
}