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/code reduction generators #804

Merged
merged 6 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

## [0.9.0] - 2023-11-08

### Added

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

## [0.8.0] - 2023-10-31

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,46 @@ public class RequestInformation {
/** Creates a new instance of the request information class. */
public RequestInformation() { //Default constructor
}
/**
* Creates a new instance of the request information class.
* @param method The HTTP method for the request.
* @param urlTemplate The url template for the request.
* @param pathParameters The path parameters for the request.
*/
public RequestInformation(final HttpMethod method, @Nonnull final String urlTemplate, @Nonnull final Map<String, Object> pathParameters) {
this.httpMethod = method;
this.urlTemplate = Objects.requireNonNull(urlTemplate);
this.pathParameters = Objects.requireNonNull(pathParameters);
}
/**
* Configures the request information based on the request configuration and the query parameters getter.
* @param <T> The type of the request configuration.
* @param requestConfiguration The request configuration to apply to the request information.
* @param configurationFactory The factory to create the request configuration from.
*/
public <T extends BaseRequestConfiguration> void configure(@Nullable final java.util.function.Consumer<T> requestConfiguration, @Nonnull final java.util.function.Supplier<T> configurationFactory) {
configure(requestConfiguration, configurationFactory, null);
}
/**
* Configures the request information based on the request configuration and the query parameters getter.
* @param <T> The type of the request configuration.
* @param requestConfiguration The request configuration to apply to the request information.
* @param configurationFactory The factory to create the request configuration from.
* @param queryParametersGetter The function to get the query parameters from the request configuration.
*/
public <T extends BaseRequestConfiguration> void configure(@Nullable final java.util.function.Consumer<T> requestConfiguration, @Nonnull final java.util.function.Supplier<T> configurationFactory, @Nullable final java.util.function.Function<T, Object> queryParametersGetter) {
baywet marked this conversation as resolved.
Show resolved Hide resolved
Objects.requireNonNull(configurationFactory);
if (requestConfiguration == null) {
return;
}
final T requestConfig = configurationFactory.get();
requestConfiguration.accept(requestConfig);
if (queryParametersGetter != null) {
addQueryParameters(queryParametersGetter.apply(requestConfig));
}
headers.putAll(requestConfig.headers);
addRequestOptions(requestConfig.options);
}
/** The url template for the current request */
@Nullable
public String urlTemplate;
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ org.gradle.caching=true

mavenGroupId = com.microsoft.kiota
mavenMajorVersion = 0
mavenMinorVersion = 8
mavenMinorVersion = 9
mavenPatchVersion = 0
mavenArtifactSuffix =

Expand Down