Skip to content

Commit 5117748

Browse files
Merge pull request #3 from speakeasy-api/feature/spe-130
2 parents 79893f8 + b9b5f63 commit 5117748

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

configuration.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ func (app SpeakeasyApp) registerApiAndSetStats(ctx context.Context, schemaFilePa
9696
for path, pathItem := range app.Schema.Paths {
9797
// register api
9898
method, op := methodAndOpFromPathItem(ctx, path, pathItem)
99-
api := apis.Api{WorkspaceID: app.WorkspaceID, Method: method, Path: path, DisplayName: op.OperationID, Description: op.Summary}
10099
unhashedApiID := app.WorkspaceID + method + path
101100
apiID := strconv.FormatUint(uint64(utils.Hash(unhashedApiID)), 10)
102-
go app.registerApi(api, apiID)
101+
api := apis.Api{WorkspaceID: app.WorkspaceID, Method: method, Path: path, DisplayName: op.OperationID, Description: op.Summary, ApiID: apiID}
102+
go app.registerApi(api)
103103
app.ApiStatsById[apiID] = &metrics.ApiStats{NumCalls: 0, NumErrors: 0}
104104
app.ApiByPath[path] = api
105105

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/jinzhu/inflection v1.0.0 // indirect
1616
github.com/jinzhu/now v1.1.4 // indirect
1717
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e // indirect
18-
github.com/speakeasy-api/speakeasy-schemas v0.0.0-20220630204841-52908f36f6c5 // indirect
18+
github.com/speakeasy-api/speakeasy-schemas v0.0.0-20220706203759-a102a61fdb5f // indirect
1919
go.uber.org/atomic v1.7.0 // indirect
2020
go.uber.org/multierr v1.6.0 // indirect
2121
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ github.com/speakeasy-api/speakeasy-schemas v0.0.0-20220629094746-07ab4fd649ae h1
101101
github.com/speakeasy-api/speakeasy-schemas v0.0.0-20220629094746-07ab4fd649ae/go.mod h1:g0yz/bfH6EDcBmACdbqM7BQtTzUrBfhJoIgDb6AsKRQ=
102102
github.com/speakeasy-api/speakeasy-schemas v0.0.0-20220630204841-52908f36f6c5 h1:gwwXbJZZP3oju0Kb/qHBmP7T88WQKeX+lyAOVu0SujM=
103103
github.com/speakeasy-api/speakeasy-schemas v0.0.0-20220630204841-52908f36f6c5/go.mod h1:g0yz/bfH6EDcBmACdbqM7BQtTzUrBfhJoIgDb6AsKRQ=
104+
github.com/speakeasy-api/speakeasy-schemas v0.0.0-20220706203759-a102a61fdb5f h1:hQPmgv7I9AHT9kXF9BIVSAmY+Rz2NsmrFBRvf+fpt/4=
105+
github.com/speakeasy-api/speakeasy-schemas v0.0.0-20220706203759-a102a61fdb5f/go.mod h1:g0yz/bfH6EDcBmACdbqM7BQtTzUrBfhJoIgDb6AsKRQ=
104106
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
105107
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
106108
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=

speakeasy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ func (app SpeakeasyApp) sendApiStatsToSpeakeasy(ctx context.Context, apiStatsByI
7878
}
7979
}
8080

81-
func (app SpeakeasyApp) registerApi(api apis.Api, apiID string) {
81+
func (app SpeakeasyApp) registerApi(api apis.Api) {
8282
ctx := log.WithFields(context.Background(), zap.Any("api", api))
8383

8484
bytesRepresentation, err := json.Marshal(api)
8585
if err != nil {
8686
log.From(ctx).Error("failed to encode Api", zap.Error(err))
8787
return
8888
}
89-
apiEndpoint := app.ServerURL + fmt.Sprintf("/rs/v1/apis/%s", apiID)
89+
apiEndpoint := app.ServerURL + fmt.Sprintf("/rs/v1/apis/%s", api.ApiID)
9090
req, err := http.NewRequest(http.MethodPost, apiEndpoint, bytes.NewBuffer(bytesRepresentation))
9191
if err != nil {
9292
log.From(ctx).Error("failed to create http request for Speakeasy api endpoint", zap.String("req_path", apiEndpoint), zap.Error(err))

0 commit comments

Comments
 (0)