Blame vendor/github.com/getkin/kin-openapi/openapi3/info.go

Packit Service 3a6627
package openapi3
Packit Service 3a6627
Packit Service 3a6627
import (
Packit Service 3a6627
	"context"
Packit Service 3a6627
	"errors"
Packit Service 3a6627
Packit Service 3a6627
	"github.com/getkin/kin-openapi/jsoninfo"
Packit Service 3a6627
)
Packit Service 3a6627
Packit Service 3a6627
// Info is specified by OpenAPI/Swagger standard version 3.0.
Packit Service 3a6627
type Info struct {
Packit Service 3a6627
	ExtensionProps
Packit Service 3a6627
	Title          string   `json:"title" yaml:"title"` // Required
Packit Service 3a6627
	Description    string   `json:"description,omitempty" yaml:"description,omitempty"`
Packit Service 3a6627
	TermsOfService string   `json:"termsOfService,omitempty" yaml:"termsOfService,omitempty"`
Packit Service 3a6627
	Contact        *Contact `json:"contact,omitempty" yaml:"contact,omitempty"`
Packit Service 3a6627
	License        *License `json:"license,omitempty" yaml:"license,omitempty"`
Packit Service 3a6627
	Version        string   `json:"version" yaml:"version"` // Required
Packit Service 3a6627
}
Packit Service 3a6627
Packit Service 3a6627
func (value *Info) MarshalJSON() ([]byte, error) {
Packit Service 3a6627
	return jsoninfo.MarshalStrictStruct(value)
Packit Service 3a6627
}
Packit Service 3a6627
Packit Service 3a6627
func (value *Info) UnmarshalJSON(data []byte) error {
Packit Service 3a6627
	return jsoninfo.UnmarshalStrictStruct(data, value)
Packit Service 3a6627
}
Packit Service 3a6627
Packit Service 3a6627
func (value *Info) Validate(c context.Context) error {
Packit Service 3a6627
	if contact := value.Contact; contact != nil {
Packit Service 3a6627
		if err := contact.Validate(c); err != nil {
Packit Service 3a6627
			return err
Packit Service 3a6627
		}
Packit Service 3a6627
	}
Packit Service 3a6627
Packit Service 3a6627
	if license := value.License; license != nil {
Packit Service 3a6627
		if err := license.Validate(c); err != nil {
Packit Service 3a6627
			return err
Packit Service 3a6627
		}
Packit Service 3a6627
	}
Packit Service 3a6627
Packit Service 3a6627
	if value.Version == "" {
Packit Service 3a6627
		return errors.New("value of version must be a non-empty JSON string")
Packit Service 3a6627
	}
Packit Service 3a6627
Packit Service 3a6627
	if value.Title == "" {
Packit Service 3a6627
		return errors.New("value of title must be a non-empty JSON string")
Packit Service 3a6627
	}
Packit Service 3a6627
Packit Service 3a6627
	return nil
Packit Service 3a6627
}
Packit Service 3a6627
Packit Service 3a6627
// Contact is specified by OpenAPI/Swagger standard version 3.0.
Packit Service 3a6627
type Contact struct {
Packit Service 3a6627
	ExtensionProps
Packit Service 3a6627
	Name  string `json:"name,omitempty" yaml:"name,omitempty"`
Packit Service 3a6627
	URL   string `json:"url,omitempty" yaml:"url,omitempty"`
Packit Service 3a6627
	Email string `json:"email,omitempty" yaml:"email,omitempty"`
Packit Service 3a6627
}
Packit Service 3a6627
Packit Service 3a6627
func (value *Contact) MarshalJSON() ([]byte, error) {
Packit Service 3a6627
	return jsoninfo.MarshalStrictStruct(value)
Packit Service 3a6627
}
Packit Service 3a6627
Packit Service 3a6627
func (value *Contact) UnmarshalJSON(data []byte) error {
Packit Service 3a6627
	return jsoninfo.UnmarshalStrictStruct(data, value)
Packit Service 3a6627
}
Packit Service 3a6627
Packit Service 3a6627
func (value *Contact) Validate(c context.Context) error {
Packit Service 3a6627
	return nil
Packit Service 3a6627
}
Packit Service 3a6627
Packit Service 3a6627
// License is specified by OpenAPI/Swagger standard version 3.0.
Packit Service 3a6627
type License struct {
Packit Service 3a6627
	ExtensionProps
Packit Service 3a6627
	Name string `json:"name" yaml:"name"` // Required
Packit Service 3a6627
	URL  string `json:"url,omitempty" yaml:"url,omitempty"`
Packit Service 3a6627
}
Packit Service 3a6627
Packit Service 3a6627
func (value *License) MarshalJSON() ([]byte, error) {
Packit Service 3a6627
	return jsoninfo.MarshalStrictStruct(value)
Packit Service 3a6627
}
Packit Service 3a6627
Packit Service 3a6627
func (value *License) UnmarshalJSON(data []byte) error {
Packit Service 3a6627
	return jsoninfo.UnmarshalStrictStruct(data, value)
Packit Service 3a6627
}
Packit Service 3a6627
Packit Service 3a6627
func (value *License) Validate(c context.Context) error {
Packit Service 3a6627
	if value.Name == "" {
Packit Service 3a6627
		return errors.New("value of license name must be a non-empty JSON string")
Packit Service 3a6627
	}
Packit Service 3a6627
	return nil
Packit Service 3a6627
}