Skip to content

Commit

Permalink
Fix: remove empty request param
Browse files Browse the repository at this point in the history
  • Loading branch information
markruler committed Mar 29, 2021
1 parent fdf6c92 commit ac56c85
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ test: fmt
.PHONY: test

testv: fmt
go test ./... -v
.PHONY: testv

test-verbose-cover: fmt
go test ./... -v --cover
.PHONY: testv

Expand Down
2 changes: 1 addition & 1 deletion pkg/excel/api_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (xl *Excel) setAPISheetRequest(operation *spec.Operation) {

if param.Schema != nil {
xl.parameterSchema(param)
continue
}

if param.Items != nil && param.Items.Enum != nil {
Expand All @@ -46,7 +47,6 @@ func (xl *Excel) setAPISheetRequest(operation *spec.Operation) {
if param.Enum != nil {
xl.File.SetCellStr(xl.Context.worksheetName, fmt.Sprintf("%s%d", "E", xl.Context.row), enum2string(param.Enum...))
}
// TODO: remove empty row
xl.Context.row++
}
xl.Context.row++
Expand Down
43 changes: 25 additions & 18 deletions pkg/excel/api_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ func TestParameterSchemaWithRef(t *testing.T) {
},
},
},
{
ParamProps: spec.ParamProps{
Name: "limit",
In: "query",
Description: "Return this number of most recently created containers, including\nnon-running ones.\n",
},
SimpleSchema: spec.SimpleSchema{
Type: "integer",
},
},
{
ParamProps: spec.ParamProps{
Name: "user",
Expand All @@ -130,7 +140,6 @@ func TestParameterSchemaWithRef(t *testing.T) {
Enum: []interface{}{"recover"},
Type: []string{"string"},
},
// TODO: need to handle extra props? this header used in common?
ExtraProps: map[string]interface{}{
"x-enum-descriptions": "recover meeting recording",
},
Expand All @@ -151,28 +160,26 @@ func TestParameterSchemaWithRef(t *testing.T) {
assert.Equal(t, "query", row[12][2])
assert.Equal(t, "integer", row[12][3])
assert.Equal(t, "The number of records returned within a single API call", row[12][6])
// TODO: remove empty row
// assert.Equal(t, "O", row[13][0])
// assert.Equal(t, "User", row[13][1])
// assert.Equal(t, "body", row[13][2])
// assert.Equal(t, "object", row[13][3])
// assert.Equal(t, "Created user object", row[13][6])
// assert.Equal(t, "O", row[14][0])
// assert.Equal(t, "action", row[14][1])
// assert.Equal(t, "body", row[14][2])
// assert.Equal(t, "string", row[14][3])
// assert.Equal(t, "", row[14][6])
// assert.Equal(t, "recover meeting recording", row[14][6])

assert.Equal(t, "X", row[13][0])
assert.Equal(t, "limit", row[13][1])
assert.Equal(t, "query", row[13][2])
assert.Equal(t, "integer", row[13][3])
assert.Equal(t, "Return this number of most recently created containers, including\nnon-running ones.\n", row[13][6])

assert.Equal(t, "O", row[14][0])
assert.Equal(t, "User", row[14][1])
assert.Equal(t, "body", row[14][2])
assert.Equal(t, "object", row[14][3])
assert.Equal(t, "Created user object", row[14][6])
assert.Equal(t, "O", row[16][0])
assert.Equal(t, "action", row[16][1])
assert.Equal(t, "body", row[16][2])
assert.Equal(t, "string", row[16][3])
assert.Equal(t, "", row[16][6])

assert.Equal(t, "O", row[15][0])
assert.Equal(t, "action", row[15][1])
assert.Equal(t, "body", row[15][2])
assert.Equal(t, "string", row[15][3])
assert.Equal(t, "", row[15][6])

// TODO: ExtraProps
// assert.Equal(t, "recover meeting recording", row[15][6])
}

Expand Down
1 change: 0 additions & 1 deletion pkg/excel/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func (xl *Excel) parameterSchema(param spec.Parameter) error {
xl.File.SetCellStr(xl.Context.worksheetName, fmt.Sprintf("%s%d", "G", xl.Context.row), param.Schema.Description)
}

xl.Context.row++
return nil
}

Expand Down

0 comments on commit ac56c85

Please sign in to comment.