mirror of
https://github.com/rancher/norman.git
synced 2025-09-08 18:49:31 +00:00
Add norman field attribute "pointer"
Add a new field attribute "pointer" to indicate that the generated
client code for the field must be a pointer. This allows clients to
differentiate between sending nil/leaving the value unset and sending an
empty map or slice.
This change also removes the `nullablestring` norman type introduced in
30f8d18
since schemas that need a pointer to a string can now use this
field attribute. There are no libraries currently using this feature so
it should be safe to remove.
Example usage:
```
Labels map[string]string `json:"labels" norman:"pointer"`
```
Resulting API schema:
```
"labels": {
"create": true,
"nullable": true,
"pointer": true,
"type": "map[string]",
"update": true
}
```
Generated client code:
```
Labels *map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
```
This commit is contained in:
@@ -382,8 +382,6 @@ func ConvertSimple(fieldType string, value interface{}, op Operation) (interface
|
||||
return convert.ToString(value), nil
|
||||
case "reference":
|
||||
return convert.ToString(value), nil
|
||||
case "nullablestring":
|
||||
return convert.ToString(value), nil
|
||||
}
|
||||
|
||||
return nil, ErrComplexType
|
||||
|
Reference in New Issue
Block a user