forked from loafle/openapi-generator-original
* Add RequiredError * Add IsZeroValue helper * Add AssertRequired method to all models * Add AssertRequired call for body param * Regenerate files * Add DisallowUnknownFields * Regenerate samples * Use hasRequired in model to remove unnecessary code * Revert disallowUnknownFields * Use isAdditionalPropertiesTrue for disallowing unknown fields * Updated samples * Fix indent * Add require checks for nested slices * Add new tests * Regenerate samples * Regenerate samples after merging
49 lines
1.3 KiB
Go
49 lines
1.3 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"`
|
|
}
|
|
|
|
// AssertUserRequired checks if the required fields are not zero-ed
|
|
func AssertUserRequired(obj User) error {
|
|
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)
|
|
})
|
|
}
|