Skip to content

Commit

Permalink
fix: response row number
Browse files Browse the repository at this point in the history
  • Loading branch information
markruler committed Apr 6, 2021
1 parent 8929592 commit e2cf81a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 4 additions & 3 deletions xlsx/simple/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (simple *Simple) setAPISheetRequest(parameters []parser.APIRequest) {

for _, param := range parameters {
xl.File.SetCellStyle(xl.WorkSheetName, fmt.Sprintf("%s%d", "A", xl.Context.Row), fmt.Sprintf("%s%d", "E", xl.Context.Row), xl.Style.Center)
xl.File.SetCellStyle(xl.WorkSheetName, fmt.Sprintf("%s%d", "F", xl.Context.Row), fmt.Sprintf("%s%d", "F", xl.Context.Row), xl.Style.Left)
xl.File.SetCellStyle(xl.WorkSheetName, fmt.Sprintf("%s%d", "F", xl.Context.Row), fmt.Sprintf("%s%d", "G", xl.Context.Row), xl.Style.Left)
simple.setCellWithOneRequest(param)
xl.Context.Row++
}
Expand All @@ -127,9 +127,10 @@ func (simple *Simple) setAPISheetResponse(responses []parser.APIResponse) {
xl.Context.Row++

for _, response := range responses {
xl.File.SetCellStyle(xl.WorkSheetName, fmt.Sprintf("%s%d", "A", xl.Context.Row), fmt.Sprintf("%s%d", "F", xl.Context.Row), xl.Style.Center)
xl.File.SetCellStyle(xl.WorkSheetName, fmt.Sprintf("%s%d", "G", xl.Context.Row), fmt.Sprintf("%s%d", "G", xl.Context.Row), xl.Style.Left)
xl.File.SetCellStyle(xl.WorkSheetName, fmt.Sprintf("%s%d", "A", xl.Context.Row), fmt.Sprintf("%s%d", "E", xl.Context.Row), xl.Style.Center)
xl.File.SetCellStyle(xl.WorkSheetName, fmt.Sprintf("%s%d", "F", xl.Context.Row), fmt.Sprintf("%s%d", "G", xl.Context.Row), xl.Style.Left)
simple.setCellWithOneResponse(response)
xl.Context.Row++
}
}

Expand Down
19 changes: 18 additions & 1 deletion xlsx/simple/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestCreateSimpleAPISheet_Request(t *testing.T) {
assert.Equal(t, "Return all containers. By default, only running containers are shown.\n", row[12][6])
}

func TestResponseHeaders(t *testing.T) {
func TestCreateSimpleAPISheet_HeaderTypeResponse(t *testing.T) {
simple := New()
xl := simple.GetExcel()
xl.SwageSpec = &parser.SwageSpec{
Expand All @@ -74,6 +74,13 @@ func TestResponseHeaders(t *testing.T) {
DataType: "string",
Description: "A base64 - encoded JSON object with some filesystem header\ninformation about the path\n",
},
{
StatusCode: "400",
Schema: "ErrorResponse",
ResponseType: "body",
DataType: "object",
Description: "error",
},
},
},
},
Expand All @@ -89,5 +96,15 @@ func TestResponseHeaders(t *testing.T) {
assert.Equal(t, "X-Docker-Container-Path-Stat", row[15][1])
assert.Equal(t, "header", row[15][2])
assert.Equal(t, "string", row[15][3])
assert.Equal(t, "", row[15][4])
assert.Equal(t, "", row[15][5])
assert.Equal(t, "A base64 - encoded JSON object with some filesystem header\ninformation about the path\n", row[15][6])

assert.Equal(t, "400", row[16][0])
assert.Equal(t, "ErrorResponse", row[16][1])
assert.Equal(t, "body", row[16][2])
assert.Equal(t, "object", row[16][3])
assert.Equal(t, "", row[16][4])
assert.Equal(t, "", row[16][5])
assert.Equal(t, "error", row[16][6])
}

0 comments on commit e2cf81a

Please sign in to comment.