mirror of
				https://github.com/OpenAPITools/openapi-generator.git
				synced 2025-11-04 10:43:44 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			333 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			333 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
/*
 | 
						|
Echo Server API
 | 
						|
 | 
						|
Echo Server API
 | 
						|
 | 
						|
API version: 0.1.0
 | 
						|
Contact: team@openapitools.org
 | 
						|
*/
 | 
						|
 | 
						|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
 | 
						|
 | 
						|
package openapi
 | 
						|
 | 
						|
import (
 | 
						|
	"encoding/json"
 | 
						|
	"bytes"
 | 
						|
	"fmt"
 | 
						|
)
 | 
						|
 | 
						|
// checks if the Pet type satisfies the MappedNullable interface at compile time
 | 
						|
var _ MappedNullable = &Pet{}
 | 
						|
 | 
						|
// Pet struct for Pet
 | 
						|
type Pet struct {
 | 
						|
	Id *int64 `json:"id,omitempty"`
 | 
						|
	Name string `json:"name"`
 | 
						|
	Category *Category `json:"category,omitempty"`
 | 
						|
	PhotoUrls []string `json:"photoUrls"`
 | 
						|
	Tags []Tag `json:"tags,omitempty"`
 | 
						|
	// pet status in the store
 | 
						|
	Status *string `json:"status,omitempty"`
 | 
						|
}
 | 
						|
 | 
						|
type _Pet Pet
 | 
						|
 | 
						|
// NewPet instantiates a new Pet object
 | 
						|
// This constructor will assign default values to properties that have it defined,
 | 
						|
// and makes sure properties required by API are set, but the set of arguments
 | 
						|
// will change when the set of required properties is changed
 | 
						|
func NewPet(name string, photoUrls []string) *Pet {
 | 
						|
	this := Pet{}
 | 
						|
	this.Name = name
 | 
						|
	this.PhotoUrls = photoUrls
 | 
						|
	return &this
 | 
						|
}
 | 
						|
 | 
						|
// NewPetWithDefaults instantiates a new Pet object
 | 
						|
// This constructor will only assign default values to properties that have it defined,
 | 
						|
// but it doesn't guarantee that properties required by API are set
 | 
						|
func NewPetWithDefaults() *Pet {
 | 
						|
	this := Pet{}
 | 
						|
	return &this
 | 
						|
}
 | 
						|
 | 
						|
// GetId returns the Id field value if set, zero value otherwise.
 | 
						|
func (o *Pet) GetId() int64 {
 | 
						|
	if o == nil || IsNil(o.Id) {
 | 
						|
		var ret int64
 | 
						|
		return ret
 | 
						|
	}
 | 
						|
	return *o.Id
 | 
						|
}
 | 
						|
 | 
						|
// GetIdOk returns a tuple with the Id field value if set, nil otherwise
 | 
						|
// and a boolean to check if the value has been set.
 | 
						|
func (o *Pet) GetIdOk() (*int64, bool) {
 | 
						|
	if o == nil || IsNil(o.Id) {
 | 
						|
		return nil, false
 | 
						|
	}
 | 
						|
	return o.Id, true
 | 
						|
}
 | 
						|
 | 
						|
// HasId returns a boolean if a field has been set.
 | 
						|
func (o *Pet) HasId() bool {
 | 
						|
	if o != nil && !IsNil(o.Id) {
 | 
						|
		return true
 | 
						|
	}
 | 
						|
 | 
						|
	return false
 | 
						|
}
 | 
						|
 | 
						|
// SetId gets a reference to the given int64 and assigns it to the Id field.
 | 
						|
func (o *Pet) SetId(v int64) {
 | 
						|
	o.Id = &v
 | 
						|
}
 | 
						|
 | 
						|
// GetName returns the Name field value
 | 
						|
func (o *Pet) GetName() string {
 | 
						|
	if o == nil {
 | 
						|
		var ret string
 | 
						|
		return ret
 | 
						|
	}
 | 
						|
 | 
						|
	return o.Name
 | 
						|
}
 | 
						|
 | 
						|
// GetNameOk returns a tuple with the Name field value
 | 
						|
// and a boolean to check if the value has been set.
 | 
						|
func (o *Pet) GetNameOk() (*string, bool) {
 | 
						|
	if o == nil {
 | 
						|
		return nil, false
 | 
						|
	}
 | 
						|
	return &o.Name, true
 | 
						|
}
 | 
						|
 | 
						|
// SetName sets field value
 | 
						|
func (o *Pet) SetName(v string) {
 | 
						|
	o.Name = v
 | 
						|
}
 | 
						|
 | 
						|
// GetCategory returns the Category field value if set, zero value otherwise.
 | 
						|
func (o *Pet) GetCategory() Category {
 | 
						|
	if o == nil || IsNil(o.Category) {
 | 
						|
		var ret Category
 | 
						|
		return ret
 | 
						|
	}
 | 
						|
	return *o.Category
 | 
						|
}
 | 
						|
 | 
						|
// GetCategoryOk returns a tuple with the Category field value if set, nil otherwise
 | 
						|
// and a boolean to check if the value has been set.
 | 
						|
func (o *Pet) GetCategoryOk() (*Category, bool) {
 | 
						|
	if o == nil || IsNil(o.Category) {
 | 
						|
		return nil, false
 | 
						|
	}
 | 
						|
	return o.Category, true
 | 
						|
}
 | 
						|
 | 
						|
// HasCategory returns a boolean if a field has been set.
 | 
						|
func (o *Pet) HasCategory() bool {
 | 
						|
	if o != nil && !IsNil(o.Category) {
 | 
						|
		return true
 | 
						|
	}
 | 
						|
 | 
						|
	return false
 | 
						|
}
 | 
						|
 | 
						|
// SetCategory gets a reference to the given Category and assigns it to the Category field.
 | 
						|
func (o *Pet) SetCategory(v Category) {
 | 
						|
	o.Category = &v
 | 
						|
}
 | 
						|
 | 
						|
// GetPhotoUrls returns the PhotoUrls field value
 | 
						|
func (o *Pet) GetPhotoUrls() []string {
 | 
						|
	if o == nil {
 | 
						|
		var ret []string
 | 
						|
		return ret
 | 
						|
	}
 | 
						|
 | 
						|
	return o.PhotoUrls
 | 
						|
}
 | 
						|
 | 
						|
// GetPhotoUrlsOk returns a tuple with the PhotoUrls field value
 | 
						|
// and a boolean to check if the value has been set.
 | 
						|
func (o *Pet) GetPhotoUrlsOk() ([]string, bool) {
 | 
						|
	if o == nil {
 | 
						|
		return nil, false
 | 
						|
	}
 | 
						|
	return o.PhotoUrls, true
 | 
						|
}
 | 
						|
 | 
						|
// SetPhotoUrls sets field value
 | 
						|
func (o *Pet) SetPhotoUrls(v []string) {
 | 
						|
	o.PhotoUrls = v
 | 
						|
}
 | 
						|
 | 
						|
// GetTags returns the Tags field value if set, zero value otherwise.
 | 
						|
func (o *Pet) GetTags() []Tag {
 | 
						|
	if o == nil || IsNil(o.Tags) {
 | 
						|
		var ret []Tag
 | 
						|
		return ret
 | 
						|
	}
 | 
						|
	return o.Tags
 | 
						|
}
 | 
						|
 | 
						|
// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
 | 
						|
// and a boolean to check if the value has been set.
 | 
						|
func (o *Pet) GetTagsOk() ([]Tag, bool) {
 | 
						|
	if o == nil || IsNil(o.Tags) {
 | 
						|
		return nil, false
 | 
						|
	}
 | 
						|
	return o.Tags, true
 | 
						|
}
 | 
						|
 | 
						|
// HasTags returns a boolean if a field has been set.
 | 
						|
func (o *Pet) HasTags() bool {
 | 
						|
	if o != nil && !IsNil(o.Tags) {
 | 
						|
		return true
 | 
						|
	}
 | 
						|
 | 
						|
	return false
 | 
						|
}
 | 
						|
 | 
						|
// SetTags gets a reference to the given []Tag and assigns it to the Tags field.
 | 
						|
func (o *Pet) SetTags(v []Tag) {
 | 
						|
	o.Tags = v
 | 
						|
}
 | 
						|
 | 
						|
// GetStatus returns the Status field value if set, zero value otherwise.
 | 
						|
func (o *Pet) GetStatus() string {
 | 
						|
	if o == nil || IsNil(o.Status) {
 | 
						|
		var ret string
 | 
						|
		return ret
 | 
						|
	}
 | 
						|
	return *o.Status
 | 
						|
}
 | 
						|
 | 
						|
// GetStatusOk returns a tuple with the Status field value if set, nil otherwise
 | 
						|
// and a boolean to check if the value has been set.
 | 
						|
func (o *Pet) GetStatusOk() (*string, bool) {
 | 
						|
	if o == nil || IsNil(o.Status) {
 | 
						|
		return nil, false
 | 
						|
	}
 | 
						|
	return o.Status, true
 | 
						|
}
 | 
						|
 | 
						|
// HasStatus returns a boolean if a field has been set.
 | 
						|
func (o *Pet) HasStatus() bool {
 | 
						|
	if o != nil && !IsNil(o.Status) {
 | 
						|
		return true
 | 
						|
	}
 | 
						|
 | 
						|
	return false
 | 
						|
}
 | 
						|
 | 
						|
// SetStatus gets a reference to the given string and assigns it to the Status field.
 | 
						|
func (o *Pet) SetStatus(v string) {
 | 
						|
	o.Status = &v
 | 
						|
}
 | 
						|
 | 
						|
func (o Pet) MarshalJSON() ([]byte, error) {
 | 
						|
	toSerialize,err := o.ToMap()
 | 
						|
	if err != nil {
 | 
						|
		return []byte{}, err
 | 
						|
	}
 | 
						|
	return json.Marshal(toSerialize)
 | 
						|
}
 | 
						|
 | 
						|
func (o Pet) ToMap() (map[string]interface{}, error) {
 | 
						|
	toSerialize := map[string]interface{}{}
 | 
						|
	if !IsNil(o.Id) {
 | 
						|
		toSerialize["id"] = o.Id
 | 
						|
	}
 | 
						|
	toSerialize["name"] = o.Name
 | 
						|
	if !IsNil(o.Category) {
 | 
						|
		toSerialize["category"] = o.Category
 | 
						|
	}
 | 
						|
	toSerialize["photoUrls"] = o.PhotoUrls
 | 
						|
	if !IsNil(o.Tags) {
 | 
						|
		toSerialize["tags"] = o.Tags
 | 
						|
	}
 | 
						|
	if !IsNil(o.Status) {
 | 
						|
		toSerialize["status"] = o.Status
 | 
						|
	}
 | 
						|
	return toSerialize, nil
 | 
						|
}
 | 
						|
 | 
						|
func (o *Pet) UnmarshalJSON(data []byte) (err error) {
 | 
						|
	// This validates that all required properties are included in the JSON object
 | 
						|
	// by unmarshalling the object into a generic map with string keys and checking
 | 
						|
	// that every required field exists as a key in the generic map.
 | 
						|
	requiredProperties := []string{
 | 
						|
		"name",
 | 
						|
		"photoUrls",
 | 
						|
	}
 | 
						|
 | 
						|
	allProperties := make(map[string]interface{})
 | 
						|
 | 
						|
	err = json.Unmarshal(data, &allProperties)
 | 
						|
 | 
						|
	if err != nil {
 | 
						|
		return err;
 | 
						|
	}
 | 
						|
 | 
						|
	for _, requiredProperty := range(requiredProperties) {
 | 
						|
		if _, exists := allProperties[requiredProperty]; !exists {
 | 
						|
			return fmt.Errorf("no value given for required property %v", requiredProperty)
 | 
						|
		}
 | 
						|
	}
 | 
						|
 | 
						|
	varPet := _Pet{}
 | 
						|
 | 
						|
	decoder := json.NewDecoder(bytes.NewReader(data))
 | 
						|
	decoder.DisallowUnknownFields()
 | 
						|
	err = decoder.Decode(&varPet)
 | 
						|
 | 
						|
	if err != nil {
 | 
						|
		return err
 | 
						|
	}
 | 
						|
 | 
						|
	*o = Pet(varPet)
 | 
						|
 | 
						|
	return err
 | 
						|
}
 | 
						|
 | 
						|
type NullablePet struct {
 | 
						|
	value *Pet
 | 
						|
	isSet bool
 | 
						|
}
 | 
						|
 | 
						|
func (v NullablePet) Get() *Pet {
 | 
						|
	return v.value
 | 
						|
}
 | 
						|
 | 
						|
func (v *NullablePet) Set(val *Pet) {
 | 
						|
	v.value = val
 | 
						|
	v.isSet = true
 | 
						|
}
 | 
						|
 | 
						|
func (v NullablePet) IsSet() bool {
 | 
						|
	return v.isSet
 | 
						|
}
 | 
						|
 | 
						|
func (v *NullablePet) Unset() {
 | 
						|
	v.value = nil
 | 
						|
	v.isSet = false
 | 
						|
}
 | 
						|
 | 
						|
func NewNullablePet(val *Pet) *NullablePet {
 | 
						|
	return &NullablePet{value: val, isSet: true}
 | 
						|
}
 | 
						|
 | 
						|
func (v NullablePet) MarshalJSON() ([]byte, error) {
 | 
						|
	return json.Marshal(v.value)
 | 
						|
}
 | 
						|
 | 
						|
func (v *NullablePet) UnmarshalJSON(src []byte) error {
 | 
						|
	v.isSet = true
 | 
						|
	return json.Unmarshal(src, &v.value)
 | 
						|
}
 | 
						|
 | 
						|
 |