-
Notifications
You must be signed in to change notification settings - Fork 0
/
baseObject.go
39 lines (36 loc) · 1.14 KB
/
baseObject.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
package swagger
import "reflect"
// Base object include all common fields of responses and parameters
type BaseObject struct {
// Type name
TypeName string `json:"type,omitempty"`
// List of enumeration values
Enum []interface{} `json:"enum,omitempty"`
// Default value
Default interface{} `json:"default,omitempty"`
// Example of value
Example interface{} `json:"example,omitempty"`
// Could it be null?
Nullable string `json:"nullable,omitempty"`
// Detailed object description
Description string `json:"description,omitempty"`
// Name of object
Name string `json:"name,omitempty"`
// Object format, for example: int64 is integer with format int64
Format string `json:"format,omitempty"`
// Reference to a schema definition
Ref string `json:"$ref,omitempty"`
// The object schema
Schema *Schema `json:"schema,omitempty"`
// Kind of object
Type reflect.Kind `json:"-"`
//
AdditionalProperties *AdditionalProperties `json:"additionalProperties,omitempty"`
}
func NewBaseObject(name, description string, t interface{}) *BaseObject {
return &BaseObject{
Name: name,
Description: description,
Schema: NewSchema(t),
}
}