Skip to content

Commit dc521f6

Browse files
chore(internal): codegen related update (#56)
1 parent 20b4808 commit dc521f6

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

internal/requestconfig/requestconfig.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"io"
1111
"math"
1212
"math/rand"
13+
"mime"
1314
"net/http"
1415
"net/url"
1516
"runtime"
@@ -485,7 +486,8 @@ func (cfg *RequestConfig) Execute() (err error) {
485486

486487
// If we are not json, return plaintext
487488
contentType := res.Header.Get("content-type")
488-
isJSON := strings.Contains(contentType, "application/json") || strings.Contains(contentType, "application/vnd.api+json")
489+
mediaType, _, _ := mime.ParseMediaType(contentType)
490+
isJSON := strings.Contains(mediaType, "application/json") || strings.HasSuffix(mediaType, "+json")
489491
if !isJSON {
490492
switch dst := cfg.ResponseBodyInto.(type) {
491493
case *string:
@@ -496,7 +498,7 @@ func (cfg *RequestConfig) Execute() (err error) {
496498
case *[]byte:
497499
*dst = contents
498500
default:
499-
return fmt.Errorf("expected destination type of 'string' or '[]byte' for responses with content-type that is not 'application/json'")
501+
return fmt.Errorf("expected destination type of 'string' or '[]byte' for responses with content-type '%s' that is not 'application/json'", contentType)
500502
}
501503
return nil
502504
}

scripts/bootstrap

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7-
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
7+
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then
88
brew bundle check >/dev/null 2>&1 || {
99
echo "==> Installing Homebrew dependencies…"
1010
brew bundle

0 commit comments

Comments
 (0)