forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_species.go
77 lines (61 loc) · 1.7 KB
/
model_species.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
/*
* 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 (
"fmt"
)
type Species string
// List of Species
const (
CAT Species = "cat"
DOG Species = "dog"
FISH Species = "fish"
GOAT Species = "goat"
PIG Species = "pig"
)
// AllowedSpeciesEnumValues is all the allowed values of Species enum
var AllowedSpeciesEnumValues = []Species{
"cat",
"dog",
"fish",
"goat",
"pig",
}
// validSpeciesEnumValue provides a map of Speciess for fast verification of use input
var validSpeciesEnumValues = map[Species]struct{}{
"cat": {},
"dog": {},
"fish": {},
"goat": {},
"pig": {},
}
// IsValid return true if the value is valid for the enum, false otherwise
func (v Species) IsValid() bool {
_, ok := validSpeciesEnumValues[v]
return ok
}
// NewSpeciesFromValue returns a pointer to a valid Species
// for the value passed as argument, or an error if the value passed is not allowed by the enum
func NewSpeciesFromValue(v string) (Species, error) {
ev := Species(v)
if ev.IsValid() {
return ev, nil
} else {
return "", fmt.Errorf("invalid value '%v' for Species: valid values are %v", v, AllowedSpeciesEnumValues)
}
}
// AssertSpeciesRequired checks if the required fields are not zero-ed
func AssertSpeciesRequired(obj Species) error {
return nil
}
// AssertSpeciesConstraints checks if the values respects the defined constraints
func AssertSpeciesConstraints(obj Species) error {
return nil
}