diff --git a/CHANGELOG.md b/CHANGELOG.md index 616868bcc6..b5cc10de57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Renames middlewareoption into requestoption to stay agnostic from implementation #635 + ## [0.0.9] - 2021-10-01 ### Added diff --git a/abstractions/dotnet/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs b/abstractions/dotnet/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs index 91517d0199..73b1fabe6b 100644 --- a/abstractions/dotnet/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs +++ b/abstractions/dotnet/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs @@ -42,7 +42,7 @@ public void SetUriExtractsQueryParameters() [Fact] - public void AddsAndRemovesMiddlewareOptions() + public void AddsAndRemovesRequestOptions() { // Arrange var testRequest = new RequestInformation() @@ -50,17 +50,17 @@ public void AddsAndRemovesMiddlewareOptions() HttpMethod = HttpMethod.GET, URI = new Uri("http://localhost") }; - var testMiddleWareOption = new Mock().Object; - Assert.Empty(testRequest.MiddlewareOptions); + var testMiddleWareOption = new Mock().Object; + Assert.Empty(testRequest.RequestOptions); // Act - testRequest.AddMiddlewareOptions(testMiddleWareOption); + testRequest.AddRequestOptions(testMiddleWareOption); // Assert - Assert.NotEmpty(testRequest.MiddlewareOptions); - Assert.Equal(testMiddleWareOption, testRequest.MiddlewareOptions.First()); + Assert.NotEmpty(testRequest.RequestOptions); + Assert.Equal(testMiddleWareOption, testRequest.RequestOptions.First()); // Act by removing the option - testRequest.RemoveMiddlewareOptions(testMiddleWareOption); - Assert.Empty(testRequest.MiddlewareOptions); + testRequest.RemoveRequestOptions(testMiddleWareOption); + Assert.Empty(testRequest.RequestOptions); } } } diff --git a/abstractions/dotnet/src/IMiddlewareOption.cs b/abstractions/dotnet/src/IRequestOption.cs similarity index 92% rename from abstractions/dotnet/src/IMiddlewareOption.cs rename to abstractions/dotnet/src/IRequestOption.cs index 8dff58f654..762efb7b80 100644 --- a/abstractions/dotnet/src/IMiddlewareOption.cs +++ b/abstractions/dotnet/src/IRequestOption.cs @@ -7,7 +7,7 @@ namespace Microsoft.Kiota.Abstractions /// /// Represents a middleware option. /// - public interface IMiddlewareOption + public interface IRequestOption { } } diff --git a/abstractions/dotnet/src/NativeResponseWrapper.cs b/abstractions/dotnet/src/NativeResponseWrapper.cs index bf979a5fc2..ce15f38e2f 100644 --- a/abstractions/dotnet/src/NativeResponseWrapper.cs +++ b/abstractions/dotnet/src/NativeResponseWrapper.cs @@ -20,13 +20,13 @@ public class NativeResponseWrapper /// The original request to make /// The query parameters of the request /// The request headers of the request - /// Request options for HTTP middlewares + /// Request options /// public static async Task CallAndGetNativeType( - Func, Action>, IEnumerable, IResponseHandler, Task> originalCall, + Func, Action>, IEnumerable, IResponseHandler, Task> originalCall, Action q = default, Action> h = default, - IEnumerable o = default) where NativeResponseType : class + IEnumerable o = default) where NativeResponseType : class { var responseHandler = new NativeResponseHandler(); await originalCall.Invoke(q, h, o, responseHandler); @@ -41,13 +41,13 @@ public static async Task CallAndGetNativeTypeThe request body of the request /// The query parameters of the request /// The request headers of the request - /// Request options for HTTP middlewares + /// Request options public static async Task CallAndGetNativeType( - Func, Action>, IEnumerable, IResponseHandler, Task> originalCall, + Func, Action>, IEnumerable, IResponseHandler, Task> originalCall, RequestBodyType requestBody, Action q = default, Action> h = default, - IEnumerable o = default) where NativeResponseType : class + IEnumerable o = default) where NativeResponseType : class { var responseHandler = new NativeResponseHandler(); await originalCall.Invoke(requestBody, q, h, o, responseHandler); diff --git a/abstractions/dotnet/src/RequestInformation.cs b/abstractions/dotnet/src/RequestInformation.cs index 8a72d8415c..4e8698c8f1 100644 --- a/abstractions/dotnet/src/RequestInformation.cs +++ b/abstractions/dotnet/src/RequestInformation.cs @@ -60,31 +60,31 @@ public void SetURI(string currentPath, string pathSegment, bool isRawUrl) /// The Request Body. /// public Stream Content { get; set; } - private Dictionary _middlewareOptions = new Dictionary(StringComparer.OrdinalIgnoreCase); + private Dictionary _requestOptions = new Dictionary(StringComparer.OrdinalIgnoreCase); /// - /// Gets the middleware options for this request. Options are unique by type. If an option of the same type is added twice, the last one wins. + /// Gets the options for this request. Options are unique by type. If an option of the same type is added twice, the last one wins. /// - public IEnumerable MiddlewareOptions { get { return _middlewareOptions.Values; } } + public IEnumerable RequestOptions { get { return _requestOptions.Values; } } /// - /// Adds a middleware option to the request. + /// Adds an option to the request. /// - /// The middleware option to add. - public void AddMiddlewareOptions(params IMiddlewareOption[] options) + /// The option to add. + public void AddRequestOptions(params IRequestOption[] options) { if(!(options?.Any() ?? false)) return; // it's a no-op if there are no options and this avoid having to check in the code gen. foreach(var option in options.Where(x => x != null)) - if(!_middlewareOptions.TryAdd(option.GetType().FullName, option)) - _middlewareOptions[option.GetType().FullName] = option; + if(!_requestOptions.TryAdd(option.GetType().FullName, option)) + _requestOptions[option.GetType().FullName] = option; } /// - /// Removes given middleware options from the current request. + /// Removes given options from the current request. /// - /// Middleware options to remove. - public void RemoveMiddlewareOptions(params IMiddlewareOption[] options) + /// Options to remove. + public void RemoveRequestOptions(params IRequestOption[] options) { if(!options?.Any() ?? false) throw new ArgumentNullException(nameof(options)); foreach(var optionName in options.Where(x => x != null).Select(x => x.GetType().FullName)) - _middlewareOptions.Remove(optionName); + _requestOptions.Remove(optionName); } private const string BinaryContentType = "application/octet-stream"; private const string ContentTypeHeader = "Content-Type"; diff --git a/abstractions/go/middleware_option.go b/abstractions/go/middleware_option.go index be74386631..8c005f800f 100644 --- a/abstractions/go/middleware_option.go +++ b/abstractions/go/middleware_option.go @@ -1,4 +1,4 @@ package abstractions -type MiddlewareOption interface { +type RequestOption interface { } diff --git a/abstractions/go/request_information.go b/abstractions/go/request_information.go index afdbabc328..d0b8494b31 100644 --- a/abstractions/go/request_information.go +++ b/abstractions/go/request_information.go @@ -18,7 +18,7 @@ type RequestInformation struct { Headers map[string]string QueryParameters map[string]string Content []byte - options map[string]MiddlewareOption + options map[string]RequestOption } func NewRequestInformation() *RequestInformation { @@ -26,7 +26,7 @@ func NewRequestInformation() *RequestInformation { URI: u.URL{}, Headers: make(map[string]string), QueryParameters: make(map[string]string), - options: make(map[string]MiddlewareOption), + options: make(map[string]RequestOption), } } @@ -63,12 +63,12 @@ func (request *RequestInformation) SetUri(currentPath string, pathSegment string return nil } -func (request *RequestInformation) AddMiddlewareOptions(options ...MiddlewareOption) error { +func (request *RequestInformation) AddRequestOptions(options ...RequestOption) error { if options == nil { - return errors.New("MiddlewareOptions cannot be nil") + return errors.New("RequestOptions cannot be nil") } if request.options == nil { - request.options = make(map[string]MiddlewareOption, len(options)) + request.options = make(map[string]RequestOption, len(options)) } for _, option := range options { tp := reflect.TypeOf(option) @@ -78,11 +78,11 @@ func (request *RequestInformation) AddMiddlewareOptions(options ...MiddlewareOpt return nil } -func (request *RequestInformation) GetMiddlewareOptions() []MiddlewareOption { +func (request *RequestInformation) GetRequestOptions() []RequestOption { if request.options == nil { - return []MiddlewareOption{} + return []RequestOption{} } - result := make([]MiddlewareOption, len(request.options)) + result := make([]RequestOption, len(request.options)) for _, option := range request.options { result = append(result, option) } diff --git a/abstractions/java/lib/src/main/java/com/microsoft/kiota/NativeResponseWrapper.java b/abstractions/java/lib/src/main/java/com/microsoft/kiota/NativeResponseWrapper.java index 5182df86fe..d0813581bb 100644 --- a/abstractions/java/lib/src/main/java/com/microsoft/kiota/NativeResponseWrapper.java +++ b/abstractions/java/lib/src/main/java/com/microsoft/kiota/NativeResponseWrapper.java @@ -14,10 +14,10 @@ public class NativeResponseWrapper { @SuppressWarnings("unchecked") @Nonnull public static CompletableFuture CallAndGetNativeType( - @Nonnull final QuadFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, + @Nonnull final QuadFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, @Nullable final Consumer q, @Nullable final Consumer> h, - @Nullable final Collection o) { + @Nullable final Collection o) { Objects.requireNonNull(originalCall, "parameter originalCall cannot be null"); final NativeResponseHandler responseHandler = new NativeResponseHandler(); return originalCall.apply(q, h, o, responseHandler).thenApply((val) -> { @@ -26,30 +26,30 @@ public static CompletableFu } @Nonnull public static CompletableFuture CallAndGetNativeType( - @Nonnull final QuadFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, + @Nonnull final QuadFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, @Nullable final Consumer q, @Nullable final Consumer> h) { return CallAndGetNativeType(originalCall, q, h, null); } @Nonnull public static CompletableFuture CallAndGetNativeType( - @Nonnull final QuadFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, + @Nonnull final QuadFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, @Nullable final Consumer q) { return CallAndGetNativeType(originalCall, q, null, null); } @Nonnull public static CompletableFuture CallAndGetNativeType( - @Nonnull final QuadFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall) { + @Nonnull final QuadFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall) { return CallAndGetNativeType(originalCall, null, null, null); } @SuppressWarnings("unchecked") @Nonnull public static CompletableFuture CallWithBodyAndGetNativeType( - @Nonnull final PentaFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, + @Nonnull final PentaFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, @Nonnull final RequestBodyType requestBody, @Nullable final Consumer q, @Nullable final Consumer> h, - @Nullable final Collection o) { + @Nullable final Collection o) { Objects.requireNonNull(originalCall, "parameter originalCall cannot be null"); Objects.requireNonNull(requestBody, "parameter requestBody cannot be null"); final NativeResponseHandler responseHandler = new NativeResponseHandler(); @@ -59,7 +59,7 @@ public static CompletableFuture CallWithBodyAndGetNativeType( - @Nonnull final PentaFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, + @Nonnull final PentaFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, @Nonnull final RequestBodyType requestBody, @Nullable final Consumer q, @Nullable final Consumer> h) { @@ -67,14 +67,14 @@ public static CompletableFuture CallWithBodyAndGetNativeType( - @Nonnull final PentaFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, + @Nonnull final PentaFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, @Nonnull final RequestBodyType requestBody, @Nullable final Consumer q) { return CallWithBodyAndGetNativeType(originalCall, requestBody, q, null, null); } @Nonnull public static CompletableFuture CallWithBodyAndGetNativeType( - @Nonnull final PentaFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, + @Nonnull final PentaFunction, Consumer>, Collection, ResponseHandler, CompletableFuture> originalCall, @Nonnull final RequestBodyType requestBody) { return CallWithBodyAndGetNativeType(originalCall, requestBody, null, null, null); } diff --git a/abstractions/java/lib/src/main/java/com/microsoft/kiota/RequestInformation.java b/abstractions/java/lib/src/main/java/com/microsoft/kiota/RequestInformation.java index 1bef96353b..a2c0a9c21f 100644 --- a/abstractions/java/lib/src/main/java/com/microsoft/kiota/RequestInformation.java +++ b/abstractions/java/lib/src/main/java/com/microsoft/kiota/RequestInformation.java @@ -69,30 +69,30 @@ private void setUriFromString(final String uriString) { /** The Request Body. */ @Nullable public InputStream content; - private HashMap _middlewareOptions = new HashMap<>(); + private HashMap _requestOptions = new HashMap<>(); /** * Gets the middleware options for this request. Options are unique by type. If an option of the same type is added twice, the last one wins. * @return the middleware options for this request. */ - public Collection getMiddlewareOptions() { return _middlewareOptions.values(); } + public Collection getRequestOptions() { return _requestOptions.values(); } /** * Adds a middleware option to this request. * @param option the middleware option to add. */ - public void addMiddlewareOptions(@Nullable final MiddlewareOption... options) { + public void addRequestOptions(@Nullable final RequestOption... options) { if(options == null || options.length == 0) return; - for(final MiddlewareOption option : options) { - _middlewareOptions.put(option.getClass().getCanonicalName(), option); + for(final RequestOption option : options) { + _requestOptions.put(option.getClass().getCanonicalName(), option); } } /** * Removes a middleware option from this request. * @param option the middleware option to remove. */ - public void removeMiddlewareOptions(@Nullable final MiddlewareOption... options) { + public void removeRequestOptions(@Nullable final RequestOption... options) { if(options == null || options.length == 0) return; - for(final MiddlewareOption option : options) { - _middlewareOptions.remove(option.getClass().getCanonicalName()); + for(final RequestOption option : options) { + _requestOptions.remove(option.getClass().getCanonicalName()); } } private static String binaryContentType = "application/octet-stream"; diff --git a/abstractions/java/lib/src/main/java/com/microsoft/kiota/MiddlewareOption.java b/abstractions/java/lib/src/main/java/com/microsoft/kiota/RequestOption.java similarity index 66% rename from abstractions/java/lib/src/main/java/com/microsoft/kiota/MiddlewareOption.java rename to abstractions/java/lib/src/main/java/com/microsoft/kiota/RequestOption.java index bffcaaaf49..83c1fcf5bd 100644 --- a/abstractions/java/lib/src/main/java/com/microsoft/kiota/MiddlewareOption.java +++ b/abstractions/java/lib/src/main/java/com/microsoft/kiota/RequestOption.java @@ -1,6 +1,6 @@ package com.microsoft.kiota; /** Represents a middleware option. */ -public interface MiddlewareOption { +public interface RequestOption { } \ No newline at end of file diff --git a/abstractions/typescript/src/index.ts b/abstractions/typescript/src/index.ts index 1120333d82..1f5f8a239e 100644 --- a/abstractions/typescript/src/index.ts +++ b/abstractions/typescript/src/index.ts @@ -9,4 +9,4 @@ export * from "./nativeResponseWrapper"; export * from './serialization'; export * from './utils'; export * from './store'; -export * from './middlewareOption'; \ No newline at end of file +export * from './requestOption'; \ No newline at end of file diff --git a/abstractions/typescript/src/nativeResponseWrapper.ts b/abstractions/typescript/src/nativeResponseWrapper.ts index b76f6e5020..5d2420f954 100644 --- a/abstractions/typescript/src/nativeResponseWrapper.ts +++ b/abstractions/typescript/src/nativeResponseWrapper.ts @@ -1,9 +1,9 @@ -import { MiddlewareOption } from "./middlewareOption"; +import { RequestOption } from "./requestOption"; import { NativeResponseHandler } from "./nativeResponseHandler"; import { ResponseHandler } from "./responseHandler"; -type originalCallType = (q?: queryParametersType, h?: headersType, o?: MiddlewareOption[] | undefined, responseHandler?: ResponseHandler) => Promise; -type originalCallWithBodyType = (requestBody: requestBodyType, q?: queryParametersType, h?: headersType, o?: MiddlewareOption[] | undefined, responseHandler?: ResponseHandler) => Promise; +type originalCallType = (q?: queryParametersType, h?: headersType, o?: RequestOption[] | undefined, responseHandler?: ResponseHandler) => Promise; +type originalCallWithBodyType = (requestBody: requestBodyType, q?: queryParametersType, h?: headersType, o?: RequestOption[] | undefined, responseHandler?: ResponseHandler) => Promise; /** This class can be used to wrap a request using the fluent API and get the native response object in return. */ export class NativeResponseWrapper { @@ -11,7 +11,7 @@ export class NativeResponseWrapper { originalCall: originalCallType, q?: queryParametersType, h?: headersType, - o?: MiddlewareOption[] | undefined + o?: RequestOption[] | undefined ) : Promise => { const responseHandler = new NativeResponseHandler(); await originalCall(q, h, o, responseHandler); @@ -22,7 +22,7 @@ export class NativeResponseWrapper { requestBody: requestBodyType, q?: queryParametersType, h?: headersType, - o?: MiddlewareOption[] | undefined + o?: RequestOption[] | undefined ) : Promise => { const responseHandler = new NativeResponseHandler(); await originalCall(requestBody, q, h, o, responseHandler); diff --git a/abstractions/typescript/src/requestInformation.ts b/abstractions/typescript/src/requestInformation.ts index 8fcc6f64b3..41a7719643 100644 --- a/abstractions/typescript/src/requestInformation.ts +++ b/abstractions/typescript/src/requestInformation.ts @@ -2,7 +2,7 @@ import { HttpMethod } from "./httpMethod"; import { ReadableStream } from 'web-streams-polyfill/es2018'; import { Parsable } from "./serialization"; import { HttpCore } from "./httpCore"; -import { MiddlewareOption } from "./middlewareOption"; +import { RequestOption } from "./requestOption"; /** This class represents an abstract HTTP request. */ export class RequestInformation { @@ -43,20 +43,20 @@ export class RequestInformation { public queryParameters: Map = new Map(); //TODO: case insensitive /** The Request Headers. */ public headers: Map = new Map(); //TODO: case insensitive - private _middlewareOptions = new Map(); //TODO: case insensitive + private _requestOptions = new Map(); //TODO: case insensitive /** Gets the middleware options for the request. */ - public getMiddlewareOptions() { return this._middlewareOptions.values(); } - public addMiddlewareOptions(...options: MiddlewareOption[]) { + public getRequestOptions() { return this._requestOptions.values(); } + public addRequestOptions(...options: RequestOption[]) { if(!options || options.length === 0) return; options.forEach(option => { - this._middlewareOptions.set(option.getKey(), option); + this._requestOptions.set(option.getKey(), option); }); } /** Removes the middleware options for the request. */ - public removeMiddlewareOptions(...options: MiddlewareOption[]) { + public removeRequestOptions(...options: RequestOption[]) { if(!options || options.length === 0) return; options.forEach(option => { - this._middlewareOptions.delete(option.getKey()); + this._requestOptions.delete(option.getKey()); }); } private static binaryContentType = "application/octet-stream"; diff --git a/abstractions/typescript/src/middlewareOption.ts b/abstractions/typescript/src/requestOption.ts similarity index 79% rename from abstractions/typescript/src/middlewareOption.ts rename to abstractions/typescript/src/requestOption.ts index fa1a47ee1d..9763bf31e5 100644 --- a/abstractions/typescript/src/middlewareOption.ts +++ b/abstractions/typescript/src/requestOption.ts @@ -1,5 +1,5 @@ /** Represents a middleware option. */ -export interface MiddlewareOption { +export interface RequestOption { /** Gets the option key for when adding it to a request. Must be unique. */ getKey(): string; } \ No newline at end of file diff --git a/http/dotnet/httpclient/Microsoft.Kiota.Http.HttpClient.Tests/Extensions/HttpRequestMessageExtensionsTests.cs b/http/dotnet/httpclient/Microsoft.Kiota.Http.HttpClient.Tests/Extensions/HttpRequestMessageExtensionsTests.cs index ae3374f646..760599928b 100644 --- a/http/dotnet/httpclient/Microsoft.Kiota.Http.HttpClient.Tests/Extensions/HttpRequestMessageExtensionsTests.cs +++ b/http/dotnet/httpclient/Microsoft.Kiota.Http.HttpClient.Tests/Extensions/HttpRequestMessageExtensionsTests.cs @@ -15,7 +15,7 @@ namespace Microsoft.Kiota.Http.HttpClient.Tests.Extensions public class HttpRequestMessageExtensionsTests { [Fact] - public void GetMiddlewareOptionCanExtractMiddleWareOptionFromHttpRequestMessage() + public void GetRequestOptionCanExtractMiddleWareOptionFromHttpRequestMessage() { // Arrange var requestInfo = new RequestInformation() @@ -27,10 +27,10 @@ public void GetMiddlewareOptionCanExtractMiddleWareOptionFromHttpRequestMessage( { MaxRedirect = 7 }; - requestInfo.AddMiddlewareOptions(redirectHandlerOption); + requestInfo.AddRequestOptions(redirectHandlerOption); // Act and get a request message var requestMessage = HttpCore.GetRequestMessageFromRequestInformation(requestInfo); - var extractedOption = requestMessage.GetMiddlewareOption(); + var extractedOption = requestMessage.GetRequestOption(); // Assert Assert.NotNull(extractedOption); Assert.Equal(redirectHandlerOption, extractedOption); @@ -77,7 +77,7 @@ public async Task CloneAsyncWithHttpContent() } [Fact] - public async Task CloneAsyncWithMiddlewareOption() + public async Task CloneAsyncWithRequestOption() { var requestInfo = new RequestInformation { @@ -88,7 +88,7 @@ public async Task CloneAsyncWithMiddlewareOption() { MaxRedirect = 7 }; - requestInfo.AddMiddlewareOptions(redirectHandlerOption); + requestInfo.AddRequestOptions(redirectHandlerOption); var originalRequest = HttpCore.GetRequestMessageFromRequestInformation(requestInfo); originalRequest.Content = new StringContent("contents"); diff --git a/http/dotnet/httpclient/Microsoft.Kiota.Http.HttpClient.Tests/Middleware/TelemetryHandlerTests.cs b/http/dotnet/httpclient/Microsoft.Kiota.Http.HttpClient.Tests/Middleware/TelemetryHandlerTests.cs index d4d622f23d..9cc25c399b 100644 --- a/http/dotnet/httpclient/Microsoft.Kiota.Http.HttpClient.Tests/Middleware/TelemetryHandlerTests.cs +++ b/http/dotnet/httpclient/Microsoft.Kiota.Http.HttpClient.Tests/Middleware/TelemetryHandlerTests.cs @@ -62,7 +62,7 @@ public async Task TelemetryHandlerSelectivelyEnrichesRequestsBasedOnRequestMiddl } }; // Configures the telemetry at the request level - requestInfo.AddMiddlewareOptions(telemetryHandlerOption); + requestInfo.AddRequestOptions(telemetryHandlerOption); // Act and get a request message var requestMessage = HttpCore.GetRequestMessageFromRequestInformation(requestInfo); Assert.Empty(requestMessage.Headers); diff --git a/http/dotnet/httpclient/src/Extensions/HttpRequestMessageExtensions.cs b/http/dotnet/httpclient/src/Extensions/HttpRequestMessageExtensions.cs index e296d6e5e3..4002f20a47 100644 --- a/http/dotnet/httpclient/src/Extensions/HttpRequestMessageExtensions.cs +++ b/http/dotnet/httpclient/src/Extensions/HttpRequestMessageExtensions.cs @@ -17,18 +17,18 @@ namespace Microsoft.Kiota.Http.HttpClient.Extensions public static class HttpRequestMessageExtensions { /// - /// Gets a from + /// Gets a from /// /// /// The representation of the request. /// A middleware option - public static T GetMiddlewareOption(this HttpRequestMessage httpRequestMessage) where T : IMiddlewareOption + public static T GetRequestOption(this HttpRequestMessage httpRequestMessage) where T : IRequestOption { if(httpRequestMessage.Options.TryGetValue( - new HttpRequestOptionsKey(typeof(T).FullName), - out IMiddlewareOption middlewareOption)) + new HttpRequestOptionsKey(typeof(T).FullName), + out IRequestOption requestOption)) { - return (T)middlewareOption; + return (T)requestOption; } return default; } @@ -58,7 +58,7 @@ internal static async Task CloneAsync(this HttpRequestMessag { // HttpClient doesn't rewind streams and we have to explicitly do so. var contentStream = await originalRequest.Content.ReadAsStreamAsync(); - + if(contentStream.CanSeek) contentStream.Seek(0, SeekOrigin.Begin); diff --git a/http/dotnet/httpclient/src/HttpCore.cs b/http/dotnet/httpclient/src/HttpCore.cs index aedecd8f76..c62b7ccf71 100644 --- a/http/dotnet/httpclient/src/HttpCore.cs +++ b/http/dotnet/httpclient/src/HttpCore.cs @@ -212,8 +212,8 @@ internal static HttpRequestMessage GetRequestMessageFromRequestInformation(Reque string.Empty)), }; - if(requestInfo.MiddlewareOptions.Any()) - requestInfo.MiddlewareOptions.ToList().ForEach(x => message.Options.Set(new HttpRequestOptionsKey(x.GetType().FullName), x)); + if(requestInfo.RequestOptions.Any()) + requestInfo.RequestOptions.ToList().ForEach(x => message.Options.Set(new HttpRequestOptionsKey(x.GetType().FullName), x)); if(requestInfo.Headers?.Any() ?? false) requestInfo.Headers.Where(x => !ContentTypeHeaderName.Equals(x.Key, StringComparison.OrdinalIgnoreCase)).ToList().ForEach(x => message.Headers.Add(x.Key, x.Value)); if(requestInfo.Content != null) diff --git a/http/dotnet/httpclient/src/Middleware/ChaosHandler.cs b/http/dotnet/httpclient/src/Middleware/ChaosHandler.cs index a7c1040708..10774f898f 100644 --- a/http/dotnet/httpclient/src/Middleware/ChaosHandler.cs +++ b/http/dotnet/httpclient/src/Middleware/ChaosHandler.cs @@ -30,7 +30,7 @@ public class ChaosHandler : DelegatingHandler, IDisposable private const string Json = "application/json"; /// - /// Create a ChaosHandler. + /// Create a ChaosHandler. /// /// Optional parameter to change default behavior of handler. public ChaosHandler(ChaosHandlerOption chaosHandlerOptions = null) @@ -52,7 +52,7 @@ protected override async Task SendAsync(HttpRequestMessage throw new ArgumentNullException(nameof(request)); // Select global or per request options - var chaosHandlerOptions = request.GetMiddlewareOption() ?? _chaosHandlerOptions; + var chaosHandlerOptions = request.GetRequestOption() ?? _chaosHandlerOptions; HttpResponseMessage response = null; // Planned Chaos or Random? diff --git a/http/dotnet/httpclient/src/Middleware/Options/ChaosHandlerOption.cs b/http/dotnet/httpclient/src/Middleware/Options/ChaosHandlerOption.cs index e428275bf8..82d4677119 100644 --- a/http/dotnet/httpclient/src/Middleware/Options/ChaosHandlerOption.cs +++ b/http/dotnet/httpclient/src/Middleware/Options/ChaosHandlerOption.cs @@ -12,14 +12,14 @@ namespace Microsoft.Kiota.Http.HttpClient.Middleware.Options /// /// The Chaos Handler Option middleware class /// - public class ChaosHandlerOption : IMiddlewareOption + public class ChaosHandlerOption : IRequestOption { /// /// Percentage of responses that will have KnownChaos responses injected, assuming no PlannedChaosFactory is provided /// public int ChaosPercentLevel { get; set; } = 10; /// - /// List of failure responses that potentially could be returned when + /// List of failure responses that potentially could be returned when /// public List KnownChaos { get; set; } /// diff --git a/http/dotnet/httpclient/src/Middleware/Options/RedirectHandlerOption.cs b/http/dotnet/httpclient/src/Middleware/Options/RedirectHandlerOption.cs index 8a7a194e0f..a8d86c2af0 100644 --- a/http/dotnet/httpclient/src/Middleware/Options/RedirectHandlerOption.cs +++ b/http/dotnet/httpclient/src/Middleware/Options/RedirectHandlerOption.cs @@ -11,7 +11,7 @@ namespace Microsoft.Kiota.Http.HttpClient.Middleware.Options /// /// The redirect middleware option class /// - public class RedirectHandlerOption: IMiddlewareOption + public class RedirectHandlerOption: IRequestOption { private const int DefaultMaxRedirect = 5; private const int MaxMaxRedirect = 20; @@ -41,7 +41,7 @@ public int MaxRedirect public Func ShouldRedirect { get; set; } = (response) => true; /// - /// A boolean value to determine if we redirects are allowed if the scheme changes(e.g. https to http). Defaults to false. + /// A boolean value to determine if we redirects are allowed if the scheme changes(e.g. https to http). Defaults to false. /// public bool AllowRedirectOnSchemeChange { get; set; } = false; } diff --git a/http/dotnet/httpclient/src/Middleware/Options/RetryHandlerOption.cs b/http/dotnet/httpclient/src/Middleware/Options/RetryHandlerOption.cs index d71f3bb041..bb3fbf724b 100644 --- a/http/dotnet/httpclient/src/Middleware/Options/RetryHandlerOption.cs +++ b/http/dotnet/httpclient/src/Middleware/Options/RetryHandlerOption.cs @@ -11,7 +11,7 @@ namespace Microsoft.Kiota.Http.HttpClient.Middleware.Options /// /// The retry middleware option class /// - public class RetryHandlerOption : IMiddlewareOption + public class RetryHandlerOption : IRequestOption { internal const int DefaultDelay = 3; internal const int DefaultMaxRetry = 3; diff --git a/http/dotnet/httpclient/src/Middleware/Options/TelemetryHandlerOption.cs b/http/dotnet/httpclient/src/Middleware/Options/TelemetryHandlerOption.cs index 07851eea63..ff27edde78 100644 --- a/http/dotnet/httpclient/src/Middleware/Options/TelemetryHandlerOption.cs +++ b/http/dotnet/httpclient/src/Middleware/Options/TelemetryHandlerOption.cs @@ -7,7 +7,7 @@ namespace Microsoft.Kiota.Http.HttpClient.Middleware.Options /// /// The Telemetry middleware option class /// - public class TelemetryHandlerOption : IMiddlewareOption + public class TelemetryHandlerOption : IRequestOption { /// /// A delegate that's called to configure the with the appropriate telemetry values. diff --git a/http/dotnet/httpclient/src/Middleware/RedirectHandler.cs b/http/dotnet/httpclient/src/Middleware/RedirectHandler.cs index c1d5d065d0..88519b4a15 100644 --- a/http/dotnet/httpclient/src/Middleware/RedirectHandler.cs +++ b/http/dotnet/httpclient/src/Middleware/RedirectHandler.cs @@ -18,7 +18,7 @@ namespace Microsoft.Kiota.Http.HttpClient.Middleware public class RedirectHandler: DelegatingHandler { /// - /// Constructs a new + /// Constructs a new /// /// An OPTIONAL to configure public RedirectHandler(RedirectHandlerOption redirectOption = null) @@ -44,7 +44,7 @@ protected override async Task SendAsync(HttpRequestMessage { if(httpRequestMessage == null) throw new ArgumentNullException(nameof(httpRequestMessage)); - RedirectOption = httpRequestMessage.GetMiddlewareOption() ?? RedirectOption; + RedirectOption = httpRequestMessage.GetRequestOption() ?? RedirectOption; // send request first time to get response var response = await base.SendAsync(httpRequestMessage, cancellationToken); @@ -66,7 +66,7 @@ protected override async Task SendAsync(HttpRequestMessage // Drain response content to free responses. await response.Content.ReadAsByteArrayAsync(cancellationToken); - // general clone request with internal CloneAsync (see CloneAsync for details) extension method + // general clone request with internal CloneAsync (see CloneAsync for details) extension method var newRequest = await response.RequestMessage.CloneAsync(); // status code == 303: change request method from post to get and content to be null diff --git a/http/dotnet/httpclient/src/Middleware/RetryHandler.cs b/http/dotnet/httpclient/src/Middleware/RetryHandler.cs index 165d2190ea..700487c2bb 100644 --- a/http/dotnet/httpclient/src/Middleware/RetryHandler.cs +++ b/http/dotnet/httpclient/src/Middleware/RetryHandler.cs @@ -41,7 +41,7 @@ public RetryHandler(RetryHandlerOption retryOption = null) } /// - /// Send a HTTP request + /// Send a HTTP request /// /// The HTTP requestneeds to be sent. /// The for the request. @@ -51,7 +51,7 @@ protected override async Task SendAsync(HttpRequestMessage if(httpRequest == null) throw new ArgumentNullException(nameof(httpRequest)); - RetryOption = httpRequest.GetMiddlewareOption() ?? RetryOption; + RetryOption = httpRequest.GetRequestOption() ?? RetryOption; var response = await base.SendAsync(httpRequest, cancellationToken); @@ -65,7 +65,7 @@ protected override async Task SendAsync(HttpRequestMessage } /// - /// Retry sending the HTTP request + /// Retry sending the HTTP request /// /// The which is returned and includes the HTTP request needs to be retried. /// The for the retry. @@ -81,7 +81,7 @@ private async Task SendRetryAsync(HttpResponseMessage respo // before retry attempt and before the TooManyRetries ServiceException. await response.Content.ReadAsByteArrayAsync(cancellationToken); - // Call Delay method to get delay time from response's Retry-After header or by exponential backoff + // Call Delay method to get delay time from response's Retry-After header or by exponential backoff Task delay = Delay(response, retryCount, RetryOption.Delay, out double delayInSeconds, cancellationToken); // If client specified a retries time limit, let's honor it @@ -90,14 +90,14 @@ private async Task SendRetryAsync(HttpResponseMessage respo // Get the cumulative delay time cumulativeDelay += TimeSpan.FromSeconds(delayInSeconds); - // Check whether delay will exceed the client-specified retries time limit value + // Check whether delay will exceed the client-specified retries time limit value if(cumulativeDelay > RetryOption.RetriesTimeLimit) { return response; } } - // general clone request with internal CloneAsync (see CloneAsync for details) extension method + // general clone request with internal CloneAsync (see CloneAsync for details) extension method var request = await response.RequestMessage.CloneAsync(); // Increase retryCount and then update Retry-Attempt in request header diff --git a/http/dotnet/httpclient/src/Middleware/TelemetryHandler.cs b/http/dotnet/httpclient/src/Middleware/TelemetryHandler.cs index a7177a691c..d8cb778269 100644 --- a/http/dotnet/httpclient/src/Middleware/TelemetryHandler.cs +++ b/http/dotnet/httpclient/src/Middleware/TelemetryHandler.cs @@ -28,7 +28,7 @@ public TelemetryHandler(TelemetryHandlerOption telemetryHandlerOption = null) } /// - /// Send a HTTP request + /// Send a HTTP request /// /// The HTTP requestneeds to be sent. /// The for the request. @@ -38,7 +38,7 @@ protected override async Task SendAsync(HttpRequestMessage if(httpRequest == null) throw new ArgumentNullException(nameof(httpRequest)); - var telemetryHandlerOption = httpRequest.GetMiddlewareOption() ?? _telemetryHandlerOption; + var telemetryHandlerOption = httpRequest.GetRequestOption() ?? _telemetryHandlerOption; // use the enriched request from the handler if(telemetryHandlerOption.TelemetryConfigurator != null) diff --git a/http/java/okhttp/lib/src/main/java/com/microsoft/kiota/http/HttpCore.java b/http/java/okhttp/lib/src/main/java/com/microsoft/kiota/http/HttpCore.java index 0b2d754c63..0a6ca73d63 100644 --- a/http/java/okhttp/lib/src/main/java/com/microsoft/kiota/http/HttpCore.java +++ b/http/java/okhttp/lib/src/main/java/com/microsoft/kiota/http/HttpCore.java @@ -14,7 +14,7 @@ import com.microsoft.kiota.ApiClientBuilder; import com.microsoft.kiota.RequestInformation; -import com.microsoft.kiota.MiddlewareOption; +import com.microsoft.kiota.RequestOption; import com.microsoft.kiota.ResponseHandler; import com.microsoft.kiota.authentication.AuthenticationProvider; import com.microsoft.kiota.serialization.ParseNodeFactoryRegistry; @@ -242,7 +242,7 @@ public void writeTo(BufferedSink sink) throws IOException { for (final Map.Entry header : requestInfo.headers.entrySet()) { requestBuilder.addHeader(header.getKey(), header.getValue()); } - for(final MiddlewareOption option : requestInfo.getMiddlewareOptions()) { + for(final RequestOption option : requestInfo.getRequestOptions()) { requestBuilder.tag(option); } return requestBuilder.build(); diff --git a/http/typescript/fetch/src/httpClient.ts b/http/typescript/fetch/src/httpClient.ts index 98a59d4a58..82528c4d3a 100644 --- a/http/typescript/fetch/src/httpClient.ts +++ b/http/typescript/fetch/src/httpClient.ts @@ -1,6 +1,6 @@ import { Middleware } from "./middleware"; import { fetch } from 'cross-fetch'; -import { MiddlewareOption } from "@microsoft/kiota-abstractions"; +import { RequestOption } from "@microsoft/kiota-abstractions"; /** Default fetch client with options and a middleware pipleline for requests execution. */ export class HttpClient { @@ -22,10 +22,10 @@ export class HttpClient { * @param options request options. * @returns the promise resolving the response. */ - public fetch(url: string, options?: RequestInit, middlewareOptions?: MiddlewareOption[]): Promise { + public fetch(url: string, options?: RequestInit, requestOptions?: RequestOption[]): Promise { const finalOptions = {...this.defaultRequestSettings, ...options} as RequestInit; if(this.middlewares.length > 0 && this.middlewares[0]) - return this.middlewares[0].execute(url, finalOptions, middlewareOptions); + return this.middlewares[0].execute(url, finalOptions, requestOptions); else throw new Error("No middlewares found"); } @@ -47,7 +47,7 @@ export class HttpClient { /** Default middleware executing a request. Internal use only. */ class FetchMiddleware implements Middleware { next: Middleware | undefined; - public execute(url: string, req: RequestInit, _?: MiddlewareOption[]): Promise { + public execute(url: string, req: RequestInit, _?: RequestOption[]): Promise { return fetch(url, req); } } \ No newline at end of file diff --git a/http/typescript/fetch/src/middleware.ts b/http/typescript/fetch/src/middleware.ts index abb6ab84ee..d7edb38fd0 100644 --- a/http/typescript/fetch/src/middleware.ts +++ b/http/typescript/fetch/src/middleware.ts @@ -1,4 +1,4 @@ -import { MiddlewareOption } from "@microsoft/kiota-abstractions"; +import { RequestOption } from "@microsoft/kiota-abstractions"; /** Defines the contract for a middleware in the request execution pipeline. */ export interface Middleware { @@ -10,5 +10,5 @@ export interface Middleware { * @param url The URL of the request. * @return A promise that resolves to the response object. */ - execute(url: string, req: RequestInit, middlewareOptions?: MiddlewareOption[]): Promise; + execute(url: string, req: RequestInit, requestOptions?: RequestOption[]): Promise; } \ No newline at end of file diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs index 320ed1c9fc..16a3e078ef 100644 --- a/src/Kiota.Builder/KiotaBuilder.cs +++ b/src/Kiota.Builder/KiotaBuilder.cs @@ -670,7 +670,7 @@ private void AddRequestBuilderMethodParameters(OpenApiUrlTreeNode currentNode, O Optional = true, ParameterKind = CodeParameterKind.Options, Description = "Request options for HTTP middlewares", - Type = new CodeType { Name = "IEnumerable", ActionOf = false, IsExternal = true }, + Type = new CodeType { Name = "IEnumerable", ActionOf = false, IsExternal = true }, }; method.AddParameter(optionsParam); } diff --git a/src/Kiota.Builder/Refiners/CSharpRefiner.cs b/src/Kiota.Builder/Refiners/CSharpRefiner.cs index 38112c01bc..714934c122 100644 --- a/src/Kiota.Builder/Refiners/CSharpRefiner.cs +++ b/src/Kiota.Builder/Refiners/CSharpRefiner.cs @@ -72,7 +72,7 @@ parentClass.StartBlock is CodeClass.Declaration parentDeclaration ? new (x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.HttpCore), "Microsoft.Kiota.Abstractions", "IHttpCore"), new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator), - "Microsoft.Kiota.Abstractions", "HttpMethod", "RequestInformation", "IMiddlewareOption"), + "Microsoft.Kiota.Abstractions", "HttpMethod", "RequestInformation", "IRequestOption"), new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor), "Microsoft.Kiota.Abstractions", "IResponseHandler"), new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Serializer), diff --git a/src/Kiota.Builder/Refiners/GoRefiner.cs b/src/Kiota.Builder/Refiners/GoRefiner.cs index 94b1e3b035..0e2d7f31a3 100644 --- a/src/Kiota.Builder/Refiners/GoRefiner.cs +++ b/src/Kiota.Builder/Refiners/GoRefiner.cs @@ -146,7 +146,7 @@ private static void AddErrorImportForEnums(CodeElement currentElement) { new (x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.HttpCore), "github.com/microsoft/kiota/abstractions/go", "HttpCore"), new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator), - "github.com/microsoft/kiota/abstractions/go", "RequestInformation", "HttpMethod", "MiddlewareOption"), + "github.com/microsoft/kiota/abstractions/go", "RequestInformation", "HttpMethod", "RequestOption"), new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor), "github.com/microsoft/kiota/abstractions/go", "ResponseHandler"), new (x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.QueryParameters), @@ -172,7 +172,7 @@ private static void CorrectMethodType(CodeMethod currentMethod) { currentMethod.ReturnType.IsNullable = true; currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.Options)).ToList().ForEach(x => { x.Type.IsNullable = false; - x.Type.Name = "MiddlewareOption"; + x.Type.Name = "RequestOption"; x.Type.CollectionKind = CodeTypeBase.CodeTypeCollectionKind.Array; }); currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.QueryParameter)).ToList().ForEach(x => x.Type.Name = $"{parentClass.Name}{x.Type.Name}"); diff --git a/src/Kiota.Builder/Refiners/JavaRefiner.cs b/src/Kiota.Builder/Refiners/JavaRefiner.cs index 5a177bb3d6..fbc583db9e 100644 --- a/src/Kiota.Builder/Refiners/JavaRefiner.cs +++ b/src/Kiota.Builder/Refiners/JavaRefiner.cs @@ -69,7 +69,7 @@ private static void AddParsableInheritanceForModelClasses(CodeElement currentEle new (x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.HttpCore), "com.microsoft.kiota", "HttpCore"), new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator), - "com.microsoft.kiota", "RequestInformation", "MiddlewareOption", "HttpMethod"), + "com.microsoft.kiota", "RequestInformation", "RequestOption", "HttpMethod"), new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator), "java.net", "URISyntaxException"), new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator), @@ -133,7 +133,7 @@ private static void CorrectMethodType(CodeMethod currentMethod) { if(currentMethod.IsOfKind(CodeMethodKind.RequestExecutor, CodeMethodKind.RequestGenerator)) { if(currentMethod.IsOfKind(CodeMethodKind.RequestExecutor)) currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.ResponseHandler) && x.Type.Name.StartsWith("i", StringComparison.OrdinalIgnoreCase)).ToList().ForEach(x => x.Type.Name = x.Type.Name[1..]); - currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.Options)).ToList().ForEach(x => x.Type.Name = "Collection"); + currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.Options)).ToList().ForEach(x => x.Type.Name = "Collection"); } else if(currentMethod.IsOfKind(CodeMethodKind.Serializer)) currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.Serializer)).ToList().ForEach(x => { diff --git a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs index 0301ae689c..92bae66547 100644 --- a/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs +++ b/src/Kiota.Builder/Refiners/TypeScriptRefiner.cs @@ -73,7 +73,7 @@ private static void AddParsableInheritanceForModelClasses(CodeElement currentEle new (x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.HttpCore), "@microsoft/kiota-abstractions", "HttpCore"), new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator), - "@microsoft/kiota-abstractions", "HttpMethod", "RequestInformation", "MiddlewareOption"), + "@microsoft/kiota-abstractions", "HttpMethod", "RequestInformation", "RequestOption"), new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor), "@microsoft/kiota-abstractions", "ResponseHandler"), new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Serializer), @@ -106,7 +106,7 @@ private static void CorrectMethodType(CodeMethod currentMethod) { if(currentMethod.IsOfKind(CodeMethodKind.RequestExecutor, CodeMethodKind.RequestGenerator)) { if(currentMethod.IsOfKind(CodeMethodKind.RequestExecutor)) currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.ResponseHandler) && x.Type.Name.StartsWith("i", StringComparison.OrdinalIgnoreCase)).ToList().ForEach(x => x.Type.Name = x.Type.Name[1..]); - currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.Options)).ToList().ForEach(x => x.Type.Name = "MiddlewareOption[]"); + currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.Options)).ToList().ForEach(x => x.Type.Name = "RequestOption[]"); } else if(currentMethod.IsOfKind(CodeMethodKind.Serializer)) currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.Serializer) && x.Type.Name.StartsWith("i", StringComparison.OrdinalIgnoreCase)).ToList().ForEach(x => x.Type.Name = x.Type.Name[1..]); diff --git a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs index 150985eaaa..f24cb1b52d 100644 --- a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs @@ -192,7 +192,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req if(requestParams.headers != null) writer.WriteLine($"{requestParams.headers.Name}?.Invoke({RequestInfoVarName}.Headers);"); if(requestParams.options != null) - writer.WriteLine($"{RequestInfoVarName}.AddMiddlewareOptions({requestParams.options.Name}?.ToArray());"); + writer.WriteLine($"{RequestInfoVarName}.AddRequestOptions({requestParams.options.Name}?.ToArray());"); writer.WriteLine($"return {RequestInfoVarName};"); } private static string GetPropertyCall(CodeProperty property, string defaultValue) => property == null ? defaultValue : $"{property.Name.ToFirstCharacterUpperCase()}"; diff --git a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs index 0cd3f0e5da..1d95c546c3 100644 --- a/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs @@ -382,7 +382,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req if(requestParams.options != null) { writer.WriteLine($"if {requestParams.options.Name} != nil {{"); writer.IncreaseIndent(); - writer.WriteLine($"err = {RequestInfoVarName}.AddMiddlewareOptions({requestParams.options.Name})"); + writer.WriteLine($"err = {RequestInfoVarName}.AddRequestOptions({requestParams.options.Name})"); WriteReturnError(writer, returnType); writer.DecreaseIndent(); writer.WriteLine("}"); diff --git a/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs index b73e653ca6..b25d225196 100644 --- a/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs @@ -276,7 +276,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req if(requestParams.options != null) { writer.WriteLine($"if ({requestParams.options.Name} != null) {{"); writer.IncreaseIndent(); - writer.WriteLine($"{RequestInfoVarName}.addMiddlewareOptions({requestParams.options.Name}.toArray(new MiddlewareOption[0]));"); + writer.WriteLine($"{RequestInfoVarName}.addRequestOptions({requestParams.options.Name}.toArray(new RequestOption[0]));"); writer.DecreaseIndent(); writer.WriteLine("}"); } diff --git a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs index be51a88bd5..9dadff9ecb 100644 --- a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs @@ -234,7 +234,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req } } if(requestParams.options != null) - writer.WriteLine($"{requestParams.options.Name} && {RequestInfoVarName}.addMiddlewareOptions(...{requestParams.options.Name});"); + writer.WriteLine($"{requestParams.options.Name} && {RequestInfoVarName}.addRequestOptions(...{requestParams.options.Name});"); writer.WriteLine($"return {RequestInfoVarName};"); } private static string GetPropertyCall(CodeProperty property, string defaultValue) => property == null ? defaultValue : $"this.{property.Name}"; diff --git a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs index c8437a78cd..f20af8df84 100644 --- a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs @@ -185,7 +185,7 @@ public void WritesRequestGeneratorBody() { Assert.Contains("h?.Invoke", result); Assert.Contains("AddQueryParameters", result); Assert.Contains("SetContentFromParsable", result); - Assert.Contains("AddMiddlewareOptions", result); + Assert.Contains("AddRequestOptions", result); Assert.Contains("return requestInfo;", result); AssertExtensions.CurlyBracesAreClosed(result); } diff --git a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs index 258b8c0686..3846aac51e 100644 --- a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs @@ -197,7 +197,7 @@ public void WritesRequestGeneratorBody() { Assert.Contains("q != nil", result); Assert.Contains("qParams.AddQueryParameters(requestInfo.QueryParameters)", result); Assert.Contains("o != nil", result); - Assert.Contains("requestInfo.AddMiddlewareOptions(o)", result); + Assert.Contains("requestInfo.AddRequestOptions(o)", result); Assert.Contains("requestInfo.SetContentFromParsable(m.httpCore", result); Assert.Contains("return requestInfo, err", result); AssertExtensions.CurlyBracesAreClosed(result); diff --git a/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs index f512573a2f..832e1687b3 100644 --- a/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/Java/CodeMethodWriterTests.cs @@ -196,7 +196,7 @@ public void WritesRequestGeneratorBody() { Assert.Contains("h.accept(requestInfo.headers)", result); Assert.Contains("AddQueryParameters", result); Assert.Contains("setContentFromParsable", result); - Assert.Contains("addMiddlewareOptions", result); + Assert.Contains("addRequestOptions", result); Assert.Contains("return requestInfo;", result); AssertExtensions.CurlyBracesAreClosed(result); } @@ -213,7 +213,7 @@ public void WritesRequestGeneratorOverloadBody() { Assert.DoesNotContain("h.accept(requestInfo.headers)", result); Assert.DoesNotContain("AddQueryParameters", result); Assert.DoesNotContain("setContentFromParsable", result); - Assert.DoesNotContain("addMiddlewareOptions", result); + Assert.DoesNotContain("addRequestOptions", result); Assert.DoesNotContain("return requestInfo;", result); Assert.Contains("return methodName(b, q, h, o)", result); AssertExtensions.CurlyBracesAreClosed(result); diff --git a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs index e20b489999..19995ca2f7 100644 --- a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs @@ -184,7 +184,7 @@ public void WritesRequestGeneratorBody() { Assert.Contains("setHeadersFromRawObject", result); Assert.Contains("setQueryStringParametersFromRawObject", result); Assert.Contains("setContentFromParsable", result); - Assert.Contains("addMiddlewareOptions", result); + Assert.Contains("addRequestOptions", result); Assert.Contains("return requestInfo;", result); AssertExtensions.CurlyBracesAreClosed(result); }