Output default as part of OpenAPI (#6222)

This commit is contained in:
Jim Kalafut 2019-02-12 15:36:13 -08:00 committed by GitHub
parent 524b65cb9b
commit 6485850886
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 0 deletions

View file

@ -155,6 +155,7 @@ type OASSchema struct {
Format string `json:"format,omitempty"`
Pattern string `json:"pattern,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Default interface{} `json:"default,omitempty"`
Example interface{} `json:"example,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Required bool `json:"required,omitempty"`
@ -263,6 +264,7 @@ func documentPath(p *Path, specialPaths *logical.Paths, backendType logical.Back
Type: t.baseType,
Pattern: t.pattern,
Enum: field.AllowedValues,
Default: field.Default,
DisplayName: field.DisplayName,
DisplayValue: field.DisplayValue,
DisplaySensitive: field.DisplaySensitive,
@ -321,6 +323,7 @@ func documentPath(p *Path, specialPaths *logical.Paths, backendType logical.Back
Format: openapiField.format,
Pattern: openapiField.pattern,
Enum: field.AllowedValues,
Default: field.Default,
Required: field.Required,
Deprecated: field.Deprecated,
DisplayName: field.DisplayName,

View file

@ -326,6 +326,7 @@ func TestOpenAPI_Paths(t *testing.T) {
},
"name": {
Type: TypeNameString,
Default: "Larry",
Description: "the name",
},
"age": {

View file

@ -85,6 +85,7 @@
"name": {
"type": "string",
"description": "the name",
"default": "Larry",
"pattern": "\\w([\\w-.]*\\w)?"
}
}