Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixes #244 #247

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bench_test.go
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ import (
"testing"

"github.com/amzn/ion-go/ion"
"github.com/danielgtaylor/restish/cli"
"github.com/danielgtaylor/restish/openapi"
"github.com/barbich/restish/cli"
"github.com/barbich/restish/openapi"
"github.com/fxamacker/cbor/v2"
"github.com/shamaton/msgpack/v2"
"github.com/spf13/cobra"
4 changes: 2 additions & 2 deletions bulk/commands.go
Original file line number Diff line number Diff line change
@@ -10,9 +10,9 @@ import (
"sort"
"strings"

"github.com/barbich/restish/cli"
"github.com/barbich/restish/openapi"
"github.com/danielgtaylor/mexpr"
"github.com/danielgtaylor/restish/cli"
"github.com/danielgtaylor/restish/openapi"
"github.com/danielgtaylor/shorthand/v2"
"github.com/hexops/gotextdiff"
"github.com/hexops/gotextdiff/myers"
2 changes: 1 addition & 1 deletion bulk/commands_test.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/danielgtaylor/restish/cli"
"github.com/barbich/restish/cli"
"github.com/spf13/afero"
"github.com/stretchr/testify/require"
"gopkg.in/h2non/gock.v1"
2 changes: 1 addition & 1 deletion bulk/file.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import (
"path/filepath"
"reflect"

"github.com/danielgtaylor/restish/cli"
"github.com/barbich/restish/cli"
"github.com/spf13/afero"
"github.com/zeebo/xxh3"
)
2 changes: 1 addition & 1 deletion bulk/metadata.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import (
"strings"
"time"

"github.com/danielgtaylor/restish/cli"
"github.com/barbich/restish/cli"
"github.com/danielgtaylor/shorthand/v2"
"github.com/logrusorgru/aurora"
"github.com/schollz/progressbar/v3"
14 changes: 7 additions & 7 deletions cli/links.go
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ type Links map[string][]*Link

// LinkParser parses link relationships in a response.
type LinkParser interface {
ParseLinks(resp *Response) error
ParseLinks(base *url.URL, resp *Response) error
}

var linkParsers = []LinkParser{}
@@ -34,7 +34,7 @@ func AddLinkParser(parser LinkParser) {
// ParseLinks uses all registered LinkParsers to parse links for a response.
func ParseLinks(base *url.URL, resp *Response) error {
for _, parser := range linkParsers {
if err := parser.ParseLinks(resp); err != nil {
if err := parser.ParseLinks(base, resp); err != nil {
return err
}
}
@@ -58,7 +58,7 @@ func ParseLinks(base *url.URL, resp *Response) error {
type LinkHeaderParser struct{}

// ParseLinks processes the links in a parsed response.
func (l LinkHeaderParser) ParseLinks(resp *Response) error {
func (l LinkHeaderParser) ParseLinks(base *url.URL, resp *Response) error {
if resp.Headers["Link"] != "" {
links, err := link.Parse(resp.Headers["Link"])
if err != nil {
@@ -90,7 +90,7 @@ type halBody struct {
type HALParser struct{}

// ParseLinks processes the links in a parsed response.
func (h HALParser) ParseLinks(resp *Response) error {
func (h HALParser) ParseLinks(base *url.URL, resp *Response) error {
entries := []interface{}{}
if l, ok := resp.Body.([]interface{}); ok {
entries = l
@@ -122,7 +122,7 @@ func (h HALParser) ParseLinks(resp *Response) error {
type TerrificallySimpleJSONParser struct{}

// ParseLinks processes the links in a parsed response.
func (t TerrificallySimpleJSONParser) ParseLinks(resp *Response) error {
func (t TerrificallySimpleJSONParser) ParseLinks(base *url.URL, resp *Response) error {
return t.walk(resp, "self", resp.Body)
}

@@ -181,7 +181,7 @@ type sirenBody struct {
type SirenParser struct{}

// ParseLinks processes the links in a parsed response.
func (s SirenParser) ParseLinks(resp *Response) error {
func (s SirenParser) ParseLinks(base *url.URL, resp *Response) error {
siren := sirenBody{}
if err := mapstructure.Decode(resp.Body, &siren); err == nil {
for _, link := range siren.Links {
@@ -230,7 +230,7 @@ func getJSONAPIlinks(links map[string]interface{}, resp *Response, isItem bool)
type JSONAPIParser struct{}

// ParseLinks processes the links in a parsed response.
func (j JSONAPIParser) ParseLinks(resp *Response) error {
func (j JSONAPIParser) ParseLinks(base *url.URL, resp *Response) error {
if b, ok := resp.Body.(map[string]interface{}); ok {
// Find top-level links
if l, ok := b["links"].(map[string]interface{}); ok {
18 changes: 10 additions & 8 deletions cli/links_test.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,9 @@ import (

type errorLinkParser struct{}

func (p errorLinkParser) ParseLinks(r *Response) error {
var base *url.URL

func (p errorLinkParser) ParseLinks(base *url.URL, r *Response) error {
return fmt.Errorf("error parsing links")
}

@@ -35,15 +37,15 @@ func TestLinkHeaderParser(t *testing.T) {
}

p := LinkHeaderParser{}
err := p.ParseLinks(r)
err := p.ParseLinks(base, r)
assert.NoError(t, err)
assert.Equal(t, r.Links["self"][0].URI, "/self")
assert.Equal(t, r.Links["item"][0].URI, "/foo")
assert.Equal(t, r.Links["item"][1].URI, "/bar")

// Test a bad link header
r.Headers["Link"] = "bad value"
err = p.ParseLinks(r)
err = p.ParseLinks(base, r)
assert.Error(t, err)
}

@@ -64,7 +66,7 @@ func TestHALParser(t *testing.T) {
}

p := HALParser{}
err := p.ParseLinks(r)
err := p.ParseLinks(base, r)
assert.NoError(t, err)
assert.Equal(t, r.Links["self"][0].URI, "/self")
assert.Equal(t, r.Links["item"][0].URI, "/item")
@@ -92,7 +94,7 @@ func TestHALParserArray(t *testing.T) {
}

p := HALParser{}
err := p.ParseLinks(r)
err := p.ParseLinks(base, r)
assert.NoError(t, err)
assert.Equal(t, r.Links["self"][0].URI, "/one")
assert.Equal(t, r.Links["self"][1].URI, "/two")
@@ -129,7 +131,7 @@ func TestTerrificallySimpleJSONParser(t *testing.T) {
}

p := TerrificallySimpleJSONParser{}
err := p.ParseLinks(r)
err := p.ParseLinks(base, r)
assert.NoError(t, err)
assert.Equal(t, r.Links["self"][0].URI, "/self")
assert.Equal(t, r.Links["things-item"][0].URI, "/foo")
@@ -152,7 +154,7 @@ func TestSirenParser(t *testing.T) {
}

s := SirenParser{}
err := s.ParseLinks(r)
err := s.ParseLinks(base, r)
assert.NoError(t, err)
assert.Equal(t, r.Links["self"][0].URI, "/self")
assert.Equal(t, r.Links["one"][0].URI, "/multi")
@@ -179,7 +181,7 @@ func TestJSONAPIParser(t *testing.T) {
}

j := JSONAPIParser{}
err := j.ParseLinks(r)
err := j.ParseLinks(base, r)
assert.NoError(t, err)
assert.Equal(t, r.Links["self"][0].URI, "/self")
assert.Equal(t, r.Links["item"][0].URI, "/item")
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/danielgtaylor/restish
module github.com/barbich/restish

go 1.18
go 1.21

toolchain go1.22.1

require (
github.com/AlecAivazis/survey/v2 v2.3.6
@@ -64,7 +66,7 @@ require (
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
github.com/microcosm-cc/bluemonday v1.0.26 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.13.0 // indirect
10 changes: 9 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
@@ -95,6 +95,7 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
@@ -152,6 +153,7 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
@@ -208,9 +210,11 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
@@ -233,8 +237,9 @@ github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/microcosm-cc/bluemonday v1.0.21 h1:dNH3e4PSyE4vNX+KlRGHT5KrSvjeUkoNPwEORjffHJg=
github.com/microcosm-cc/bluemonday v1.0.21/go.mod h1:ytNkv4RrDrLJ2pqlsSI46O6IVXmZOBBD4SaJyDwwTkM=
github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58=
github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
@@ -283,6 +288,7 @@ github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/schollz/progressbar/v3 v3.12.2 h1:yLqqqpQNMxGxHY8uEshRihaHWwa0rf0yb7/Zrpgq2C0=
github.com/schollz/progressbar/v3 v3.12.2/go.mod h1:HFJYIYQQJX32UJdyoigUl19xoV6aMwZt6iX/C30RWfg=
@@ -337,6 +343,7 @@ github.com/yuin/goldmark v1.5.3/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5ta
github.com/yuin/goldmark-emoji v1.0.1 h1:ctuWEyzGBwiucEqxzwe0SOYDXPAucOrE9NQC18Wa1os=
github.com/yuin/goldmark-emoji v1.0.1/go.mod h1:2w1E6FEWLcDQkoTE+7HU6QF1F6SLlNGjRIBbIZQFqkQ=
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
@@ -685,6 +692,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY=
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -3,10 +3,10 @@ package main
import (
"os"

"github.com/danielgtaylor/restish/bulk"
"github.com/danielgtaylor/restish/cli"
"github.com/danielgtaylor/restish/oauth"
"github.com/danielgtaylor/restish/openapi"
"github.com/barbich/restish/bulk"
"github.com/barbich/restish/cli"
"github.com/barbich/restish/oauth"
"github.com/barbich/restish/openapi"
)

var version string = "dev"
2 changes: 1 addition & 1 deletion oauth/authcode.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import (

"context"

"github.com/danielgtaylor/restish/cli"
"github.com/barbich/restish/cli"
"github.com/mattn/go-isatty"
"golang.org/x/oauth2"
)
2 changes: 1 addition & 1 deletion oauth/clientcreds.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (
"net/url"
"strings"

"github.com/danielgtaylor/restish/cli"
"github.com/barbich/restish/cli"
"golang.org/x/oauth2/clientcredentials"
)

2 changes: 1 addition & 1 deletion oauth/oauth.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"errors"
"net/http"

"github.com/danielgtaylor/restish/cli"
"github.com/barbich/restish/cli"
"golang.org/x/oauth2"
)

2 changes: 1 addition & 1 deletion oauth/refresh.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"fmt"
"net/url"

"github.com/danielgtaylor/restish/cli"
"github.com/barbich/restish/cli"
"golang.org/x/oauth2"
)

2 changes: 1 addition & 1 deletion oauth/request.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (
"strings"
"time"

"github.com/danielgtaylor/restish/cli"
"github.com/barbich/restish/cli"
"golang.org/x/oauth2"
)

2 changes: 1 addition & 1 deletion openapi/openapi.go
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@ import (
"sort"
"strings"

"github.com/barbich/restish/cli"
"github.com/danielgtaylor/casing"
"github.com/danielgtaylor/restish/cli"
"github.com/danielgtaylor/shorthand/v2"
"github.com/gosimple/slug"
"github.com/pb33f/libopenapi"
2 changes: 1 addition & 1 deletion openapi/openapi_test.go
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import (
"testing"
"testing/iotest"

"github.com/danielgtaylor/restish/cli"
"github.com/barbich/restish/cli"
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"