Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: microsoft/kiota-java
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.3
Choose a base ref
...
head repository: microsoft/kiota-java
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.1.4
Choose a head ref

Commits on Apr 2, 2024

  1. Copy the full SHA
    6cf3a97 View commit details
  2. Copy the full SHA
    3c7f7d3 View commit details
  3. Bump com.gradle:gradle-enterprise-gradle-plugin

    Bumps com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17.
    
    ---
    updated-dependencies:
    - dependency-name: com.gradle:gradle-enterprise-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 2, 2024
    Copy the full SHA
    51d0644 View commit details
  4. Bump com.gradle:gradle-enterprise-gradle-plugin

    Bumps com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17.
    
    ---
    updated-dependencies:
    - dependency-name: com.gradle:gradle-enterprise-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 2, 2024
    Copy the full SHA
    5023a18 View commit details
  5. Bump com.gradle:gradle-enterprise-gradle-plugin

    Bumps com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17.
    
    ---
    updated-dependencies:
    - dependency-name: com.gradle:gradle-enterprise-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 2, 2024
    Copy the full SHA
    3c2993a View commit details
  6. Bump com.gradle:gradle-enterprise-gradle-plugin

    Bumps com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17.
    
    ---
    updated-dependencies:
    - dependency-name: com.gradle:gradle-enterprise-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 2, 2024
    Copy the full SHA
    4483f65 View commit details
  7. Bump com.gradle:gradle-enterprise-gradle-plugin

    Bumps com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17.
    
    ---
    updated-dependencies:
    - dependency-name: com.gradle:gradle-enterprise-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 2, 2024
    Copy the full SHA
    8cc79a0 View commit details
  8. Bump com.gradle:gradle-enterprise-gradle-plugin

    Bumps com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17.
    
    ---
    updated-dependencies:
    - dependency-name: com.gradle:gradle-enterprise-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 2, 2024
    Copy the full SHA
    db285ef View commit details
  9. Bump com.gradle:gradle-enterprise-gradle-plugin

    Bumps com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17.
    
    ---
    updated-dependencies:
    - dependency-name: com.gradle:gradle-enterprise-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 2, 2024
    Copy the full SHA
    90cd560 View commit details

Commits on Apr 3, 2024

  1. Merge pull request #1152 from microsoft/dependabot/gradle/components/…

    …authentication/azure/android/com.gradle-gradle-enterprise-gradle-plugin-3.17
    
    Bump com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17 in /components/authentication/azure/android
    github-actions[bot] authored Apr 3, 2024
    Copy the full SHA
    6167cf1 View commit details
  2. Merge pull request #1157 from microsoft/dependabot/gradle/components/…

    …serialization/multipart/android/com.gradle-gradle-enterprise-gradle-plugin-3.17
    
    Bump com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17 in /components/serialization/multipart/android
    github-actions[bot] authored Apr 3, 2024
    Copy the full SHA
    f3c2f06 View commit details
  3. Merge pull request #1151 from microsoft/dependabot/gradle/components/…

    …abstractions/android/com.gradle-gradle-enterprise-gradle-plugin-3.17
    
    Bump com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17 in /components/abstractions/android
    github-actions[bot] authored Apr 3, 2024
    Copy the full SHA
    19b4a55 View commit details
  4. Merge pull request #1155 from microsoft/dependabot/gradle/components/…

    …serialization/form/android/com.gradle-gradle-enterprise-gradle-plugin-3.17
    
    Bump com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17 in /components/serialization/form/android
    github-actions[bot] authored Apr 3, 2024
    Copy the full SHA
    4828501 View commit details
  5. Merge pull request #1156 from microsoft/dependabot/gradle/components/…

    …serialization/json/android/com.gradle-gradle-enterprise-gradle-plugin-3.17
    
    Bump com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17 in /components/serialization/json/android
    github-actions[bot] authored Apr 3, 2024
    Copy the full SHA
    8c638b3 View commit details
  6. Merge pull request #1154 from microsoft/dependabot/gradle/components/…

    …http/okHttp/android/com.gradle-gradle-enterprise-gradle-plugin-3.17
    
    Bump com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17 in /components/http/okHttp/android
    github-actions[bot] authored Apr 3, 2024
    Copy the full SHA
    1dc54bb View commit details
  7. Merge pull request #1153 from microsoft/dependabot/gradle/components/…

    …serialization/text/android/com.gradle-gradle-enterprise-gradle-plugin-3.17
    
    Bump com.gradle:gradle-enterprise-gradle-plugin from 3.16.2 to 3.17 in /components/serialization/text/android
    github-actions[bot] authored Apr 3, 2024
    Copy the full SHA
    6c6f4cc View commit details
  8. Apply spotless

    piotrooo committed Apr 3, 2024
    Copy the full SHA
    5180293 View commit details
  9. Add changelog entry

    piotrooo committed Apr 3, 2024
    Copy the full SHA
    3739d54 View commit details
  10. Add @nonnull annotation

    piotrooo committed Apr 3, 2024
    Copy the full SHA
    590f8a3 View commit details
  11. Cleanup

    piotrooo committed Apr 3, 2024
    Copy the full SHA
    3bd4cc8 View commit details
  12. Add changelog entry

    piotrooo committed Apr 3, 2024
    Copy the full SHA
    f346318 View commit details
  13. Copy the full SHA
    fbbcf04 View commit details
  14. Merge pull request #1149 from piotrooo/feature/remove-nullable-from-b…

    …ase-request-configuration
    
    Remove unnecessary @nullable annotations
    andrueastman authored Apr 3, 2024
    Copy the full SHA
    a7a6569 View commit details
  15. Copy the full SHA
    d2f2306 View commit details

Commits on Apr 4, 2024

  1. Merge remote-tracking branch 'origin/main' into feature/introduce-mul…

    …tipartbody-filename-directive
    Andrew Omondi committed Apr 4, 2024
    Copy the full SHA
    9700c72 View commit details
  2. Bump version for release

    Andrew Omondi committed Apr 4, 2024
    Copy the full SHA
    9781104 View commit details
  3. Copy the full SHA
    97da359 View commit details
  4. Merge pull request #1150 from piotrooo/feature/introduce-multipartbod…

    …y-filename-directive
    
    Introduce MultipartBody filename directive
    andrueastman authored Apr 4, 2024
    Copy the full SHA
    d24eb36 View commit details
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,10 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.4] - 2024-04-04

### Added

- Introduces a `filename` directive in the `MultipartBody`.

### Changed

- Replaces `@Nullable` annotations to `@Nonnull` in the `BaseRequestConfiguration`.

## [1.1.3] - 2024-04-02

### Changed
2 changes: 1 addition & 1 deletion components/abstractions/android/build.gradle
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.16.2"
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.17"
classpath "com.android.tools.build:gradle:8.3.1"
classpath "com.github.ben-manes:gradle-versions-plugin:0.51.0"
}
4 changes: 4 additions & 0 deletions components/abstractions/spotBugsExcludeFilter.xml
Original file line number Diff line number Diff line change
@@ -58,4 +58,8 @@ xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubu
<Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE" />
<Class name="com.microsoft.kiota.store.InMemoryBackingStore" />
</Match>
<Match>
<Bug pattern="SIC_INNER_SHOULD_BE_STATIC" />
<Class name="com.microsoft.kiota.MultipartBody$Part" />
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.microsoft.kiota;

import jakarta.annotation.Nullable;
import jakarta.annotation.Nonnull;

import java.util.Collections;
import java.util.List;

/** Base class for request configuration */
/**
* Base class for request configuration
*/
public abstract class BaseRequestConfiguration {
/**
* Default constructor
@@ -13,9 +16,13 @@ public BaseRequestConfiguration() {
// default empty constructor
}

/** Request headers */
@Nullable public RequestHeaders headers = new RequestHeaders();
/**
* Request headers
*/
@Nonnull public RequestHeaders headers = new RequestHeaders();

/** Request options */
@Nullable public java.util.List<RequestOption> options = Collections.emptyList();
/**
* Request options
*/
@Nonnull public List<RequestOption> options = Collections.emptyList();
}
Original file line number Diff line number Diff line change
@@ -48,19 +48,35 @@ public MultipartBody() {
*/
public <T> void addOrReplacePart(
@Nonnull final String name, @Nonnull final String contentType, @Nonnull final T value) {
addOrReplacePart(name, contentType, value, null);
}

/**
* Adds or replaces a part in the multipart body.
*
* @param <T> the type of the part to add or replace.
* @param name the name of the part to add or replace.
* @param contentType the content type of the part to add or replace.
* @param value the value of the part to add or replace.
* @param filename the value of the filename directive.
*/
public <T> void addOrReplacePart(
@Nonnull final String name,
@Nonnull final String contentType,
@Nonnull final T value,
@Nullable String filename) {
Objects.requireNonNull(value);
if (Compatibility.isBlank(contentType))
throw new IllegalArgumentException("contentType cannot be blank or empty");
if (Compatibility.isBlank(name))
throw new IllegalArgumentException("name cannot be blank or empty");

final String normalizedName = normalizePartName(name);
originalNames.put(normalizedName, name);
parts.put(normalizedName, new AbstractMap.SimpleEntry<>(contentType, value));
Part part = new Part(name, value, contentType, filename);
parts.put(normalizedName, part);
}

private final Map<String, Map.Entry<String, Object>> parts = new HashMap<>();
private final Map<String, String> originalNames = new HashMap<>();
private final Map<String, Part> parts = new HashMap<>();

private String normalizePartName(@Nonnull final String original) {
return original.toLowerCase(Locale.ROOT);
@@ -75,7 +91,7 @@ private String normalizePartName(@Nonnull final String original) {
if (Compatibility.isBlank(partName))
throw new IllegalArgumentException("partName cannot be blank or empty");
final String normalizedName = normalizePartName(partName);
final Map.Entry<String, Object> candidate = parts.get(normalizedName);
final Part candidate = parts.get(normalizedName);
if (candidate == null) return null;
return candidate.getValue();
}
@@ -90,10 +106,7 @@ public boolean removePart(@Nonnull final String partName) {
throw new IllegalArgumentException("partName cannot be blank or empty");
final String normalizedName = normalizePartName(partName);
final Object candidate = parts.remove(normalizedName);
if (candidate == null) return false;

originalNames.remove(normalizedName);
return true;
return candidate != null;
}

/** {@inheritDoc} */
@@ -111,18 +124,23 @@ public void serialize(@Nonnull final SerializationWriter writer) {
if (parts.isEmpty()) throw new IllegalStateException("multipart body cannot be empty");
final SerializationWriterFactory serializationFactory = ra.getSerializationWriterFactory();
boolean isFirst = true;
for (final Map.Entry<String, Map.Entry<String, Object>> partEntry : parts.entrySet()) {
for (final Map.Entry<String, Part> partEntry : parts.entrySet()) {
try {
Part part = partEntry.getValue();
if (isFirst) isFirst = false;
else writer.writeStringValue("", "");
writer.writeStringValue("", "--" + getBoundary());
final String partContentType = partEntry.getValue().getKey();
final String partContentType = part.getContentType();
writer.writeStringValue("Content-Type", partContentType);
writer.writeStringValue(
"Content-Disposition",
"form-data; name=\"" + originalNames.get(partEntry.getKey()) + "\"");

String contentDisposition = "form-data; name=\"" + part.getName() + "\"";
if (part.getFilename() != null && !part.getFilename().trim().isEmpty()) {
contentDisposition += "; filename=\"" + part.getFilename() + "\"";
}
writer.writeStringValue("Content-Disposition", contentDisposition);

writer.writeStringValue("", "");
final Object objectValue = partEntry.getValue().getValue();
final Object objectValue = part.getValue();
if (objectValue instanceof Parsable) {
try (final SerializationWriter partWriter =
serializationFactory.getSerializationWriter(partContentType)) {
@@ -151,4 +169,34 @@ public void serialize(@Nonnull final SerializationWriter writer) {
writer.writeStringValue("", "");
writer.writeStringValue("", "--" + boundary + "--");
}

private class Part {
private final String name;
private final Object value;
private final String contentType;
private final String filename;

Part(String name, Object value, String contentType, String filename) {
this.name = name;
this.value = value;
this.contentType = contentType;
this.filename = filename;
}

public String getName() {
return name;
}

public Object getValue() {
return value;
}

public String getContentType() {
return contentType;
}

public String getFilename() {
return filename;
}
}
}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import com.microsoft.kiota.serialization.SerializationWriter;

@@ -67,5 +68,27 @@ void removesPart() {
final Object result = multipartBody.getPartValue("foo");
assertNull(result);
}

@Test
void notAddFilename() {
final MultipartBody multipartBody = new MultipartBody();
final SerializationWriter writer = mock(SerializationWriter.class);
multipartBody.requestAdapter = mock(RequestAdapter.class);
multipartBody.addOrReplacePart("foo", "bar", "baz");
multipartBody.serialize(writer);
verify(writer).writeStringValue("Content-Disposition", "form-data; name=\"foo\"");
}

@Test
void addFilename() {
final MultipartBody multipartBody = new MultipartBody();
final SerializationWriter writer = mock(SerializationWriter.class);
multipartBody.requestAdapter = mock(RequestAdapter.class);
multipartBody.addOrReplacePart("foo", "bar", "baz", "image.png");
multipartBody.serialize(writer);
verify(writer)
.writeStringValue(
"Content-Disposition", "form-data; name=\"foo\"; filename=\"image.png\"");
}
// serialize method is being tested in the serialization library
}
2 changes: 1 addition & 1 deletion components/authentication/azure/android/build.gradle
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.16.2"
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.17"
classpath "com.android.tools.build:gradle:8.3.1"
classpath "com.github.ben-manes:gradle-versions-plugin:0.51.0"
}
2 changes: 1 addition & 1 deletion components/http/okHttp/android/build.gradle
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.16.2"
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.17"
classpath "com.android.tools.build:gradle:8.3.1"
classpath "com.github.ben-manes:gradle-versions-plugin:0.51.0"
}
2 changes: 1 addition & 1 deletion components/serialization/form/android/build.gradle
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.16.2"
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.17"
classpath "com.android.tools.build:gradle:8.3.1"
classpath "com.github.ben-manes:gradle-versions-plugin:0.51.0"
}
2 changes: 1 addition & 1 deletion components/serialization/json/android/build.gradle
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.16.2"
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.17"
classpath "com.android.tools.build:gradle:8.3.1"
classpath "com.github.ben-manes:gradle-versions-plugin:0.51.0"
}
2 changes: 1 addition & 1 deletion components/serialization/multipart/android/build.gradle
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.16.2"
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.17"
classpath "com.android.tools.build:gradle:8.3.1"
classpath "com.github.ben-manes:gradle-versions-plugin:0.51.0"
}
2 changes: 1 addition & 1 deletion components/serialization/text/android/build.gradle
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.16.2"
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.17"
classpath "com.android.tools.build:gradle:8.3.1"
classpath "com.github.ben-manes:gradle-versions-plugin:0.51.0"
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ org.gradle.caching=true
mavenGroupId = com.microsoft.kiota
mavenMajorVersion = 1
mavenMinorVersion = 1
mavenPatchVersion = 3
mavenPatchVersion = 4
mavenArtifactSuffix =

#These values are used to run functional tests