From 750dc082f1ce9f0fc772c8dd39a419228c6db3ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20Crespo?= Date: Thu, 17 Oct 2024 05:24:37 +0000 Subject: [PATCH] Bump kiota from 1.18.0 to 1.19.1 This commit fixes #13 since kiota 1.19.0 included the fix with trailing slashes in the OpenAPI.NET repo (release 1.6.22). `appendTrailingSlashHandler` is removed because the generated client is now including trailing slashes as expected by Archivematica Storage Service. All tests under the root and example modules are passing with the handler removed. --- Makefile | 2 +- ...ault_item_with_purpose_request_builder.go} | 35 ++++++++++--------- .../v2_location_default_request_builder.go | 17 +++------ kiota/api/v2_location_request_builder.go | 2 +- kiota/api/v2_pipeline_request_builder.go | 2 +- kiota/kiota-lock.json | 3 +- ssclient.go | 18 ---------- 7 files changed, 29 insertions(+), 50 deletions(-) rename kiota/api/{v2_location_default_with_purpose_item_request_builder.go => v2_location_default_item_with_purpose_request_builder.go} (62%) diff --git a/Makefile b/Makefile index 7f4cd9c..37966b5 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ examplemocks: $(MOCKGEN) .PHONY: ssclient ssclient: - @which kiota > /dev/null 2>&1 || (echo "kiota not found in PATH, download v1.18.0 from: https://learn.microsoft.com/en-ca/openapi/kiota/install" && exit 1) + @which kiota > /dev/null 2>&1 || (echo "kiota not found in PATH, download v1.19.1 from: https://learn.microsoft.com/en-ca/openapi/kiota/install" && exit 1) kiota generate --language go --clean-output --class-name Client --namespace-name go.artefactual.dev/ssclient/kiota --openapi typespec/tsp-output/@typespec/openapi3/openapi.v1.yaml --output ./kiota .PHONY: typespec diff --git a/kiota/api/v2_location_default_with_purpose_item_request_builder.go b/kiota/api/v2_location_default_item_with_purpose_request_builder.go similarity index 62% rename from kiota/api/v2_location_default_with_purpose_item_request_builder.go rename to kiota/api/v2_location_default_item_with_purpose_request_builder.go index 0b557cd..86b67be 100644 --- a/kiota/api/v2_location_default_with_purpose_item_request_builder.go +++ b/kiota/api/v2_location_default_item_with_purpose_request_builder.go @@ -6,32 +6,35 @@ import ( ia31f303b98dc4e7292d1559872ed38681eda57e78e48a431654df5b787bc8588 "go.artefactual.dev/ssclient/kiota/models" ) -// V2LocationDefaultWithPurposeItemRequestBuilder builds and executes requests for operations under \api\v2\location\default\{purpose} -type V2LocationDefaultWithPurposeItemRequestBuilder struct { +// V2LocationDefaultItemWithPurposeRequestBuilder builds and executes requests for operations under \api\v2\location\default\{purpose}\ +type V2LocationDefaultItemWithPurposeRequestBuilder struct { i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.BaseRequestBuilder } -// V2LocationDefaultWithPurposeItemRequestBuilderGetRequestConfiguration configuration for the request such as headers, query parameters, and middleware options. -type V2LocationDefaultWithPurposeItemRequestBuilderGetRequestConfiguration struct { +// V2LocationDefaultItemWithPurposeRequestBuilderGetRequestConfiguration configuration for the request such as headers, query parameters, and middleware options. +type V2LocationDefaultItemWithPurposeRequestBuilderGetRequestConfiguration struct { // Request headers Headers *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestHeaders // Request options Options []i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestOption } -// NewV2LocationDefaultWithPurposeItemRequestBuilderInternal instantiates a new V2LocationDefaultWithPurposeItemRequestBuilder and sets the default values. -func NewV2LocationDefaultWithPurposeItemRequestBuilderInternal(pathParameters map[string]string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*V2LocationDefaultWithPurposeItemRequestBuilder) { - m := &V2LocationDefaultWithPurposeItemRequestBuilder{ - BaseRequestBuilder: *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewBaseRequestBuilder(requestAdapter, "{+baseurl}/api/v2/location/default/{purpose}", pathParameters), +// NewV2LocationDefaultItemWithPurposeRequestBuilderInternal instantiates a new V2LocationDefaultItemWithPurposeRequestBuilder and sets the default values. +func NewV2LocationDefaultItemWithPurposeRequestBuilderInternal(pathParameters map[string]string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter, purpose *string)(*V2LocationDefaultItemWithPurposeRequestBuilder) { + m := &V2LocationDefaultItemWithPurposeRequestBuilder{ + BaseRequestBuilder: *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewBaseRequestBuilder(requestAdapter, "{+baseurl}/api/v2/location/default/{purpose}/", pathParameters), + } + if purpose != nil { + m.BaseRequestBuilder.PathParameters["purpose"] = *purpose } return m } -// NewV2LocationDefaultWithPurposeItemRequestBuilder instantiates a new V2LocationDefaultWithPurposeItemRequestBuilder and sets the default values. -func NewV2LocationDefaultWithPurposeItemRequestBuilder(rawUrl string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*V2LocationDefaultWithPurposeItemRequestBuilder) { +// NewV2LocationDefaultItemWithPurposeRequestBuilder instantiates a new V2LocationDefaultItemWithPurposeRequestBuilder and sets the default values. +func NewV2LocationDefaultItemWithPurposeRequestBuilder(rawUrl string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*V2LocationDefaultItemWithPurposeRequestBuilder) { urlParams := make(map[string]string) urlParams["request-raw-url"] = rawUrl - return NewV2LocationDefaultWithPurposeItemRequestBuilderInternal(urlParams, requestAdapter) + return NewV2LocationDefaultItemWithPurposeRequestBuilderInternal(urlParams, requestAdapter, nil) } // returns a ErrorEscaped error when the service returns a 400 status code -func (m *V2LocationDefaultWithPurposeItemRequestBuilder) Get(ctx context.Context, requestConfiguration *V2LocationDefaultWithPurposeItemRequestBuilderGetRequestConfiguration)(error) { +func (m *V2LocationDefaultItemWithPurposeRequestBuilder) Get(ctx context.Context, requestConfiguration *V2LocationDefaultItemWithPurposeRequestBuilderGetRequestConfiguration)(error) { requestInfo, err := m.ToGetRequestInformation(ctx, requestConfiguration); if err != nil { return err @@ -46,7 +49,7 @@ func (m *V2LocationDefaultWithPurposeItemRequestBuilder) Get(ctx context.Context return nil } // returns a *RequestInformation when successful -func (m *V2LocationDefaultWithPurposeItemRequestBuilder) ToGetRequestInformation(ctx context.Context, requestConfiguration *V2LocationDefaultWithPurposeItemRequestBuilderGetRequestConfiguration)(*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) { +func (m *V2LocationDefaultItemWithPurposeRequestBuilder) ToGetRequestInformation(ctx context.Context, requestConfiguration *V2LocationDefaultItemWithPurposeRequestBuilderGetRequestConfiguration)(*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) { requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.GET, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters) if requestConfiguration != nil { requestInfo.Headers.AddAll(requestConfiguration.Headers) @@ -56,7 +59,7 @@ func (m *V2LocationDefaultWithPurposeItemRequestBuilder) ToGetRequestInformation return requestInfo, nil } // WithUrl returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. -// returns a *V2LocationDefaultWithPurposeItemRequestBuilder when successful -func (m *V2LocationDefaultWithPurposeItemRequestBuilder) WithUrl(rawUrl string)(*V2LocationDefaultWithPurposeItemRequestBuilder) { - return NewV2LocationDefaultWithPurposeItemRequestBuilder(rawUrl, m.BaseRequestBuilder.RequestAdapter); +// returns a *V2LocationDefaultItemWithPurposeRequestBuilder when successful +func (m *V2LocationDefaultItemWithPurposeRequestBuilder) WithUrl(rawUrl string)(*V2LocationDefaultItemWithPurposeRequestBuilder) { + return NewV2LocationDefaultItemWithPurposeRequestBuilder(rawUrl, m.BaseRequestBuilder.RequestAdapter); } diff --git a/kiota/api/v2_location_default_request_builder.go b/kiota/api/v2_location_default_request_builder.go index b034c57..0bbe6d3 100644 --- a/kiota/api/v2_location_default_request_builder.go +++ b/kiota/api/v2_location_default_request_builder.go @@ -8,18 +8,6 @@ import ( type V2LocationDefaultRequestBuilder struct { i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.BaseRequestBuilder } -// ByPurpose gets an item from the go.artefactual.dev/ssclient/kiota.api.v2.location.default.item collection -// returns a *V2LocationDefaultWithPurposeItemRequestBuilder when successful -func (m *V2LocationDefaultRequestBuilder) ByPurpose(purpose string)(*V2LocationDefaultWithPurposeItemRequestBuilder) { - urlTplParams := make(map[string]string) - for idx, item := range m.BaseRequestBuilder.PathParameters { - urlTplParams[idx] = item - } - if purpose != "" { - urlTplParams["purpose"] = purpose - } - return NewV2LocationDefaultWithPurposeItemRequestBuilderInternal(urlTplParams, m.BaseRequestBuilder.RequestAdapter) -} // NewV2LocationDefaultRequestBuilderInternal instantiates a new V2LocationDefaultRequestBuilder and sets the default values. func NewV2LocationDefaultRequestBuilderInternal(pathParameters map[string]string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*V2LocationDefaultRequestBuilder) { m := &V2LocationDefaultRequestBuilder{ @@ -33,3 +21,8 @@ func NewV2LocationDefaultRequestBuilder(rawUrl string, requestAdapter i2ae4187f7 urlParams["request-raw-url"] = rawUrl return NewV2LocationDefaultRequestBuilderInternal(urlParams, requestAdapter) } +// WithPurpose builds and executes requests for operations under \api\v2\location\default\{purpose}\ +// returns a *V2LocationDefaultItemWithPurposeRequestBuilder when successful +func (m *V2LocationDefaultRequestBuilder) WithPurpose(purpose *string)(*V2LocationDefaultItemWithPurposeRequestBuilder) { + return NewV2LocationDefaultItemWithPurposeRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter, purpose) +} diff --git a/kiota/api/v2_location_request_builder.go b/kiota/api/v2_location_request_builder.go index 8641bb0..1bb98da 100644 --- a/kiota/api/v2_location_request_builder.go +++ b/kiota/api/v2_location_request_builder.go @@ -48,7 +48,7 @@ func (m *V2LocationRequestBuilder) ByUuid(uuid string)(*V2LocationWithUuItemRequ // NewV2LocationRequestBuilderInternal instantiates a new V2LocationRequestBuilder and sets the default values. func NewV2LocationRequestBuilderInternal(pathParameters map[string]string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*V2LocationRequestBuilder) { m := &V2LocationRequestBuilder{ - BaseRequestBuilder: *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewBaseRequestBuilder(requestAdapter, "{+baseurl}/api/v2/location{?description,limit,offset,order_by,pipeline__uuid,purpose,quota,relative_path,used,uuid}", pathParameters), + BaseRequestBuilder: *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewBaseRequestBuilder(requestAdapter, "{+baseurl}/api/v2/location/{?description,limit,offset,order_by,pipeline__uuid,purpose,quota,relative_path,used,uuid}", pathParameters), } return m } diff --git a/kiota/api/v2_pipeline_request_builder.go b/kiota/api/v2_pipeline_request_builder.go index d1b6f13..1523b76 100644 --- a/kiota/api/v2_pipeline_request_builder.go +++ b/kiota/api/v2_pipeline_request_builder.go @@ -38,7 +38,7 @@ func (m *V2PipelineRequestBuilder) ByUuid(uuid string)(*V2PipelineWithUuItemRequ // NewV2PipelineRequestBuilderInternal instantiates a new V2PipelineRequestBuilder and sets the default values. func NewV2PipelineRequestBuilderInternal(pathParameters map[string]string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*V2PipelineRequestBuilder) { m := &V2PipelineRequestBuilder{ - BaseRequestBuilder: *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewBaseRequestBuilder(requestAdapter, "{+baseurl}/api/v2/pipeline{?description,uuid}", pathParameters), + BaseRequestBuilder: *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewBaseRequestBuilder(requestAdapter, "{+baseurl}/api/v2/pipeline/{?description,uuid}", pathParameters), } return m } diff --git a/kiota/kiota-lock.json b/kiota/kiota-lock.json index a311745..715ef05 100644 --- a/kiota/kiota-lock.json +++ b/kiota/kiota-lock.json @@ -2,8 +2,9 @@ "descriptionHash": "282F5F42C995332838196A181E9B402A3180FC6596F46BA799E25AF9DB27EE513613C3CACEFF10B58476C1E8FD12C36A028CFEF368A3B87134A297E3C82CB1D7", "descriptionLocation": "../typespec/tsp-output/@typespec/openapi3/openapi.v1.yaml", "lockFileVersion": "1.0.0", - "kiotaVersion": "1.18.0", + "kiotaVersion": "1.19.1", "clientClassName": "Client", + "typeAccessModifier": "Public", "clientNamespaceName": "go.artefactual.dev/ssclient/kiota", "language": "Go", "usesBackingStore": false, diff --git a/ssclient.go b/ssclient.go index c3f07ff..fff47ca 100644 --- a/ssclient.go +++ b/ssclient.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "net/http" - "strings" "time" kabs "github.com/microsoft/kiota-abstractions-go" @@ -65,9 +64,6 @@ func configureMiddleware(client *http.Client) error { return err } - // Introduce our middleware to inject the trailing slash. - middlewares = append(middlewares, appendTrailingSlashHandler{}) - client.Transport = khttp.NewCustomTransportWithParentTransport(client.Transport, middlewares...) return nil @@ -90,17 +86,3 @@ func (p *authProvider) AuthenticateRequest(ctx context.Context, request *kabs.Re return nil } - -// appendTrailingSlashHandler is a middleware that ensures that the path has a -// trailing slash which is the expected in Archivematica Storage Service API. -// With TypeSpec we can sucessfully describe paths with a trailing slash, but -// Kiota drops it during generation (issue #4291). -type appendTrailingSlashHandler struct{} - -func (middleware appendTrailingSlashHandler) Intercept(pipeline khttp.Pipeline, middlewareIndex int, req *http.Request) (*http.Response, error) { - if !strings.HasSuffix(req.URL.Path, "/") { - req.URL.Path += "/" - } - - return pipeline.Next(req, middlewareIndex) -}