Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feature/generator reduction #145

Merged
merged 4 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.7.0] - 2023-11-07

### Added

- Added methods in request information to reduce the amount of code being generated.

## [1.6.1] - 2023-11-02

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Kiota.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageProjectUrl>https://aka.ms/kiota/docs</PackageProjectUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Deterministic>true</Deterministic>
<VersionPrefix>1.6.1</VersionPrefix>
<VersionPrefix>1.7.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<SignAssembly>false</SignAssembly>
Expand Down
33 changes: 33 additions & 0 deletions src/RequestInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,39 @@
/// </summary>
public class RequestInformation
{
/// <summary>
/// Creates a new instance of <see cref="RequestInformation"/>.
/// </summary>
public RequestInformation()
{

}
/// <summary>
/// Creates a new instance of <see cref="RequestInformation"/> with the given method and url template.
/// </summary>
/// <param name="method"></param>
/// <param name="urlTemplate"></param>
/// <param name="pathParameters"></param>
public RequestInformation(Method method, string urlTemplate, IDictionary<string, object> pathParameters)
{
HttpMethod = method;
UrlTemplate = urlTemplate;
PathParameters = pathParameters;
}
/// <summary>
/// Configures the current request configuration headers, query parameters, and options base on the callback provided.
/// </summary>
/// <typeparam name="T">Type for the query parameters</typeparam>
/// <param name="requestConfiguration">Callback to configure the request</param>
public void Configure<T>(Action<RequestConfiguration<T>>? requestConfiguration) where T : class, new()
{
if(requestConfiguration == null) return;
var requestConfig = new RequestConfiguration<T>();
requestConfiguration(requestConfig);
AddQueryParameters(requestConfig.QueryParameters);
AddRequestOptions(requestConfig.Options);
AddHeaders(requestConfig.Headers);
}
internal const string RawUrlKey = "request-raw-url";
private Uri? _rawUri;
/// <summary>
Expand Down Expand Up @@ -199,7 +232,7 @@
/// Sets the request body to a binary stream.
/// </summary>
/// <param name="content">The binary stream to set as a body.</param>
[Obsolete("Use SetStreamContent and pass the content type instead")]

Check warning on line 235 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Do not forget to remove this deprecated code someday. (https://rules.sonarsource.com/csharp/RSPEC-1133)

Check warning on line 235 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Do not forget to remove this deprecated code someday. (https://rules.sonarsource.com/csharp/RSPEC-1133)

Check warning on line 235 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Do not forget to remove this deprecated code someday. (https://rules.sonarsource.com/csharp/RSPEC-1133)

Check warning on line 235 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Do not forget to remove this deprecated code someday. (https://rules.sonarsource.com/csharp/RSPEC-1133)

Check warning on line 235 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Do not forget to remove this deprecated code someday. (https://rules.sonarsource.com/csharp/RSPEC-1133)
public void SetStreamContent(Stream content) => SetStreamContent(content, BinaryContentType);
/// <summary>
/// Sets the request body to a binary stream.
Expand Down Expand Up @@ -337,7 +370,7 @@
writer.WriteNullValue(null);
break;
default:
throw new InvalidOperationException($"error serialization data value with unknown type {item?.GetType()}");

Check warning on line 373 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Change this expression which always evaluates to the same result. (https://rules.sonarsource.com/csharp/RSPEC-2589)

Check warning on line 373 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Change this expression which always evaluates to the same result. (https://rules.sonarsource.com/csharp/RSPEC-2589)

Check warning on line 373 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Change this expression which always evaluates to the same result. (https://rules.sonarsource.com/csharp/RSPEC-2589)

Check warning on line 373 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Change this expression which always evaluates to the same result. (https://rules.sonarsource.com/csharp/RSPEC-2589)

Check warning on line 373 in src/RequestInformation.cs

View workflow job for this annotation

GitHub Actions / Build

Change this expression which always evaluates to the same result. (https://rules.sonarsource.com/csharp/RSPEC-2589)
}
Headers.TryAdd(ContentTypeHeader, contentType);
Content = writer.GetSerializedContent();
Expand Down