Skip to content

Commit 0d136b3

Browse files
authored
Merge pull request #269 from netlify/remove-listforms-endpoint
Remove listForms endpoint
2 parents a2e8a51 + 9271230 commit 0d136b3

File tree

4 files changed

+53
-65
lines changed

4 files changed

+53
-65
lines changed

go/plumbing/operations/operations_client.go

Lines changed: 0 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/porcelain/forms.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,10 @@ import (
66
"github.com/netlify/open-api/go/porcelain/context"
77
)
88

9-
// ListForms lists the forms a user has access to.
10-
func (n *Netlify) ListForms(ctx context.Context, params *operations.ListFormsParams) ([]*models.Form, error) {
11-
resp, err := n.Netlify.Operations.ListForms(params, context.GetAuthInfo(ctx))
12-
if err != nil {
13-
return nil, err
14-
}
15-
16-
return resp.Payload, nil
17-
}
18-
199
// ListFormsBySiteId lists the forms of a particular site
2010
func (n *Netlify) ListFormsBySiteId(ctx context.Context, siteID string) ([]*models.Form, error) {
2111
authInfo := context.GetAuthInfo(ctx)
22-
resp, err := n.Netlify.Operations.ListForms(operations.NewListFormsParams().WithSiteID(&siteID), authInfo)
12+
resp, err := n.Netlify.Operations.ListSiteForms(operations.NewListSiteFormsParams().WithSiteID(siteID), authInfo)
2313
if err != nil {
2414
return nil, err
2515
}

go/porcelain/forms_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package porcelain
2+
3+
import (
4+
"context"
5+
"net/http"
6+
"net/http/httptest"
7+
"net/url"
8+
"testing"
9+
10+
"github.com/go-openapi/runtime"
11+
apiClient "github.com/go-openapi/runtime/client"
12+
"github.com/go-openapi/strfmt"
13+
apiContext "github.com/netlify/open-api/go/porcelain/context"
14+
"github.com/stretchr/testify/assert"
15+
"github.com/stretchr/testify/require"
16+
)
17+
18+
func TestListFormsBySiteId(t *testing.T) {
19+
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
20+
rw.Header().Set("Content-Type", "application/json; charset=utf-8")
21+
rw.Write([]byte(`
22+
[
23+
{
24+
"id": "1",
25+
"site_id": "123",
26+
"name": "contact",
27+
"paths": [],
28+
"submission_count": 0,
29+
"fields": [],
30+
"created_at": ""
31+
}
32+
]`))
33+
assert.Equal(t, "/api/v1/sites/123/forms", req.URL.String())
34+
}))
35+
defer server.Close()
36+
37+
httpClient := http.DefaultClient
38+
39+
authInfo := runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error {
40+
r.SetHeaderParam("User-Agent", "buildbot")
41+
r.SetHeaderParam("Authorization", "Bearer 1234")
42+
return nil
43+
})
44+
45+
parsedURL, err := url.Parse(server.URL)
46+
require.NoError(t, err)
47+
tr := apiClient.NewWithClient(parsedURL.Host, "/api/v1", []string{"http"}, httpClient)
48+
client := NewRetryable(tr, strfmt.Default, 1)
49+
forms, err := client.ListFormsBySiteId(apiContext.WithAuthInfo(context.Background(), authInfo), "123")
50+
require.NoError(t, err)
51+
assert.Equal(t, len(forms), 1)
52+
}

swagger.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -982,24 +982,6 @@ paths:
982982
$ref: '#/definitions/pluginRun'
983983
default:
984984
$ref: '#/responses/error'
985-
/forms:
986-
get:
987-
operationId: listForms
988-
deprecated: true
989-
tags: [form]
990-
parameters:
991-
- name: site_id
992-
in: query
993-
type: string
994-
responses:
995-
'200':
996-
description: OK
997-
schema:
998-
type: array
999-
items:
1000-
$ref: '#/definitions/form'
1001-
default:
1002-
$ref: '#/responses/error'
1003985
/forms/{form_id}/submissions:
1004986
get:
1005987
operationId: listFormSubmissions

0 commit comments

Comments
 (0)