// Code generated by go-swagger; DO NOT EDIT.

package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"
	"encoding/json"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/validate"
)

// APIEncoding api encoding
//
// swagger:model apiEncoding
type APIEncoding string

func NewAPIEncoding(value APIEncoding) *APIEncoding {
	return &value
}

// Pointer returns a pointer to a freshly-allocated APIEncoding.
func (m APIEncoding) Pointer() *APIEncoding {
	return &m
}

const (

	// APIEncodingJSON captures enum value "JSON"
	APIEncodingJSON APIEncoding = "JSON"

	// APIEncodingPROTOBUF captures enum value "PROTOBUF"
	APIEncodingPROTOBUF APIEncoding = "PROTOBUF"
)

// for schema
var apiEncodingEnum []interface{}

func init() {
	var res []APIEncoding
	if err := json.Unmarshal([]byte(`["JSON","PROTOBUF"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		apiEncodingEnum = append(apiEncodingEnum, v)
	}
}

func (m APIEncoding) validateAPIEncodingEnum(path, location string, value APIEncoding) error {
	if err := validate.EnumCase(path, location, value, apiEncodingEnum, true); err != nil {
		return err
	}
	return nil
}

// Validate validates this api encoding
func (m APIEncoding) Validate(formats strfmt.Registry) error {
	var res []error

	// value enum
	if err := m.validateAPIEncodingEnum("", "body", m); err != nil {
		return err
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

// ContextValidate validates this api encoding based on context it is used
func (m APIEncoding) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}
