Skip to content

Commit

Permalink
Switch to net/http constants rather than referencing raw strings
Browse files Browse the repository at this point in the history
  • Loading branch information
brandur committed Jul 25, 2018
1 parent 78f379e commit 86a87af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"net/http"
"reflect"
"sort"
"strings"
Expand Down Expand Up @@ -225,7 +226,7 @@ func (g *DataGenerator) generateInternal(params *GenerateParams) (interface{}, e
}

if len(schema.AnyOf) != 0 {
anyOfSchema, err := g.findAnyOfBranch(schema, params.RequestMethod == "DELETE")
anyOfSchema, err := g.findAnyOfBranch(schema, params.RequestMethod == http.MethodDelete)
if err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"net/http"
"sync"
"testing"

Expand Down Expand Up @@ -292,7 +293,7 @@ func TestGenerateResponseData(t *testing.T) {
generator := DataGenerator{testSpec.Components.Schemas, &testFixtures}
data, err := generator.Generate(&GenerateParams{
// Just needs to be any HTTP method that's not DELETE
RequestMethod: "POST",
RequestMethod: http.MethodPost,
Schema: &spec.Schema{AnyOf: []*spec.Schema{
// put the deleted version first so we know it's not just
// returning the first result
Expand All @@ -311,7 +312,7 @@ func TestGenerateResponseData(t *testing.T) {
{
generator := DataGenerator{testSpec.Components.Schemas, &testFixtures}
data, err := generator.Generate(&GenerateParams{
RequestMethod: "DELETE",
RequestMethod: http.MethodDelete,
Schema: &spec.Schema{AnyOf: []*spec.Schema{
// put the non-deleted version first so we know it's not just
// returning the first result
Expand Down

0 comments on commit 86a87af

Please sign in to comment.