Skip to content

Commit

Permalink
schema.default can be array, or even other types like example
Browse files Browse the repository at this point in the history
  • Loading branch information
nasa9084 committed Jun 19, 2024
1 parent 4a81d73 commit c62c58b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions openapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1392,12 +1392,12 @@ func testUspto(t *testing.T) {
"start": &openapi.Schema{
Description: "Starting record number. Default value is 0.",
Type: "integer",
Default: "0",
Default: 0,
},
"rows": &openapi.Schema{
Description: `Specify number of rows to be returned. If you run the search with default values, in the response you will see 'numFound' attribute which will tell the number of records available in the dataset.`,
Type: "integer",
Default: "100",
Default: 100,
},
},
Required: []string{"criteria"},
Expand Down
2 changes: 1 addition & 1 deletion schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Schema struct {
AdditionalProperties *Schema `yaml:"additionalProperties"`
Description string
Format string
Default string
Default interface{}

Nullable bool
Discriminator *Discriminator
Expand Down
15 changes: 15 additions & 0 deletions schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ x-extension: val`,
},
},
},
{
data: `---
type: array
items:
type: string
default:
- foo
- bar`,
want: &openapi.Schema{
Type: "array",
Items: &openapi.Schema{
Type: "string",
},
},
},
}
for i, tt := range tests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
Expand Down

0 comments on commit c62c58b

Please sign in to comment.