forked from loafle/openapi-generator-original
* better support of inline schema in array item * update tests * update samples * regenerate samples * fix allof naming, remove files * add files * update samples * update readme * fix tests * update samples * update samples * add new files * update test spec * add back tests * remove unused files * comment out python test * update js test using own spec * remove files * remove unused files * remove files * remove unused files * better handling of allOf with a single type * comment out go test * remove test_all_of_with_single_ref_single_ref_type.py * fix inline resolver, uncomment go test
72 lines
1.8 KiB
Go
72 lines
1.8 KiB
Go
/*
|
|
* OpenAPI Petstore
|
|
*
|
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
*
|
|
* API version: 1.0.0
|
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
|
*/
|
|
|
|
package petstoreserver
|
|
|
|
// User - A User who is purchasing from the pet store
|
|
type User struct {
|
|
|
|
Id int64 `json:"id,omitempty"`
|
|
|
|
Username string `json:"username,omitempty"`
|
|
|
|
FirstName string `json:"firstName,omitempty"`
|
|
|
|
LastName string `json:"lastName,omitempty"`
|
|
|
|
Email string `json:"email,omitempty"`
|
|
|
|
Password string `json:"password,omitempty"`
|
|
|
|
Phone *string `json:"phone,omitempty"`
|
|
|
|
// User Status
|
|
UserStatus int32 `json:"userStatus,omitempty"`
|
|
|
|
// An array 1-deep.
|
|
DeepSliceModel *[][][]Tag `json:"deepSliceModel"`
|
|
|
|
// An array 1-deep.
|
|
DeepSliceMap [][]AnObject `json:"deepSliceMap,omitempty"`
|
|
}
|
|
|
|
// AssertUserRequired checks if the required fields are not zero-ed
|
|
func AssertUserRequired(obj User) error {
|
|
elements := map[string]interface{}{
|
|
"deepSliceModel": obj.DeepSliceModel,
|
|
}
|
|
for name, el := range elements {
|
|
if isZero := IsZeroValue(el); isZero {
|
|
return &RequiredError{Field: name}
|
|
}
|
|
}
|
|
|
|
if obj.DeepSliceModel != nil {
|
|
if err := AssertRecurseTagRequired(*obj.DeepSliceModel); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if err := AssertRecurseAnObjectRequired(obj.DeepSliceMap); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// AssertRecurseUserRequired recursively checks if required fields are not zero-ed in a nested slice.
|
|
// Accepts only nested slice of User (e.g. [][]User), otherwise ErrTypeAssertionError is thrown.
|
|
func AssertRecurseUserRequired(objSlice interface{}) error {
|
|
return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
|
|
aUser, ok := obj.(User)
|
|
if !ok {
|
|
return ErrTypeAssertionError
|
|
}
|
|
return AssertUserRequired(aUser)
|
|
})
|
|
}
|