Created
June 30, 2018 17:13
-
-
Save rezamt/14638089daf3b238bc64bdae9b64eb56 to your computer and use it in GitHub Desktop.
Go Yaml Parser and how to omit empty fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Body struct { | |
FormParameters map[string]NamedParameter `yaml:"formParameters,omitempty"` | |
Schema string `yaml:"schema,omitempty"` | |
Example string `yaml:"example,omitempty"` | |
Headers map[string]NamedParameter `yaml:"headers,omitempty"` | |
} | |
type NamedParameter struct { | |
DisplayName string `yaml:"displayName,omitempty"` // The parameter's display name, used for display or documentation purposes | |
Description string `yaml:"description,omitempty"` // Describes the intended use or meaning of the parameter | |
Type string `yaml:"type,omitempty"` // Primitive type of the parameter's resolved value. string, float, int, date, bool, file | |
Enum []string `yaml:"enum,omitempty"` // Enumeration of the parameter's valid values. Can only be used if type is string | |
Pattern string `yaml:"pattern,omitempty"` // Regex pattern parameter values must match. Can only be used if type is string | |
MinLength int `yaml:"minLength,omitempty"` // Minimum number of characters. Can only be used if type is string | |
MaxLength int `yaml:"maxLength,omitempty"` // Maximum number of characters. Can only be used if type is string | |
Minimum float64 `yaml:"minimum,omitempty"` // Minimum value for parameter value. Can only be used if type is number or integer | |
Maximum float64 `yaml:"maximum,omitempty"` // Maximum value for parameter value. Can only be used if type is number or integer | |
Example string `yaml:"example,omitempty"` // An example of a value for the parameter | |
Repeat bool `yaml:"repeat,omitempty"` // Whether the parameter can be repeated | |
Required bool `yaml:"required,omitempty"` // Whether the parameter is required | |
Default interface{} `yaml:"default,omitempty"` // The default value if the parameter is omitted | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment