Skip to content

Commit

Permalink
Output default as part of OpenAPI (#6222)
Browse files Browse the repository at this point in the history
  • Loading branch information
kalafut authored Feb 12, 2019
1 parent 79a07dd commit 4a7544c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions logical/framework/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions logical/framework/openapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func TestOpenAPI_Paths(t *testing.T) {
},
"name": {
Type: TypeNameString,
Default: "Larry",
Description: "the name",
},
"age": {
Expand Down
1 change: 1 addition & 0 deletions logical/framework/testdata/operations.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"name": {
"type": "string",
"description": "the name",
"default": "Larry",
"pattern": "\\w([\\w-.]*\\w)?"
}
}
Expand Down

0 comments on commit 4a7544c

Please sign in to comment.