forked from loafle/openapi-generator-original
* [go-server] Support min/max/defaults for values Enforce, for the go-server, to check the minimum and maximum values specified in the openapi description. Also apply the default if the parameter is not passed. Fix #14013 * Fix merge conflict Co-authored-by: Ween Jiann <16207788+lwj5@users.noreply.github.com> * Improve UnmarshalJSON implementation Co-authored-by: Ween Jiann <16207788+lwj5@users.noreply.github.com> * Improve default value handling for string Co-authored-by: Ween Jiann <16207788+lwj5@users.noreply.github.com> * Fix suggested changes * rework option pattern * add imports based on types/min max values --------- Co-authored-by: Ween Jiann <16207788+lwj5@users.noreply.github.com>
56 lines
1.2 KiB
Go
56 lines
1.2 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
|
|
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
|
|
|
|
// 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"`
|
|
}
|
|
|
|
// UnmarshalJSON sets *m to a copy of data while respecting defaults if specified.
|
|
func (m *User) UnmarshalJSON(data []byte) error {
|
|
|
|
type Alias User // To avoid infinite recursion
|
|
return json.Unmarshal(data, (*Alias)(m))
|
|
}
|
|
|
|
// AssertUserRequired checks if the required fields are not zero-ed
|
|
func AssertUserRequired(obj User) error {
|
|
return nil
|
|
}
|
|
|
|
// AssertUserConstraints checks if the values respects the defined constraints
|
|
func AssertUserConstraints(obj User) error {
|
|
return nil
|
|
}
|