Skip to content

Commit

Permalink
(fix): file upload test definition doesn't contain crazy undsicrimina…
Browse files Browse the repository at this point in the history
…ted unions
  • Loading branch information
dsinghvi committed Feb 21, 2024
1 parent 77954c8 commit aa8cd2d
Show file tree
Hide file tree
Showing 39 changed files with 60 additions and 1,523 deletions.
13 changes: 12 additions & 1 deletion generators/java/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.2] - 2024-02-21
- Fix: File upload endpoints no longer fail to compile because the reference to
the mime type variable is present.

```java
// Code that failed to compile
String fileMimeType = Files.probeContentType(file.toPath());
MediaType fileMediaType = fileMimeType != null ? MediaType.parse(mimeType) : null; // mimeType undefined
// Code that now compiles
MediaType fileMediaType = fileMimeType != null ? MediaType.parse(fileMimeType) : null;
```

## [0.8.1] - 2024-02-14
- Feature: The RequestOptions object now supports configuring an optional timeout to apply per-request.
```java
Expand All @@ -14,7 +26,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
client.films.list(ro);
```


## [0.8.0] - 2024-02-11
- Feature: The SDK generator now supports whitelabelling. When this is turned on,
there will be no mention of Fern in the generated code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,18 +345,19 @@ private void initializeMultipartBody(
requestBodyCodeBlock
.beginControlFlow("if ($N.isPresent())", getFilePropertyParameterName(fileProperty))
.addStatement(
"String $L = $T.probeContentType($L.toPath())",
"String $L = $T.probeContentType($L.get().toPath())",
mimeTypeVariableName,
Files.class,
filePropertyParameterName)
.addStatement(
"$T $L = $L != null ? $T.parse(mimeType) : null",
"$T $L = $L != null ? $T.parse($L) : null",
MediaType.class,
mediaTypeVariableName,
mimeTypeVariableName,
MediaType.class)
MediaType.class,
mimeTypeVariableName)
.addStatement(
"$L.addFormDataPart($S, $L.getName(), $T.create($L, $L.get()))",
"$L.addFormDataPart($S, $L.get().getName(), $T.create($L, $L.get()))",
getMultipartBodyPropertiesName(),
fileProperty.getKey().getWireValue(),
filePropertyParameterName,
Expand All @@ -372,11 +373,12 @@ private void initializeMultipartBody(
Files.class,
filePropertyParameterName)
.addStatement(
"$T $L = $L != null ? $T.parse(mimeType) : null",
"$T $L = $L != null ? $T.parse($L) : null",
MediaType.class,
mediaTypeVariableName,
mimeTypeVariableName,
MediaType.class)
MediaType.class,
mimeTypeVariableName)
.addStatement(
"$L.addFormDataPart($S, $L.getName(), $T.create($L, $L))",
getMultipartBodyPropertiesName(),
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit aa8cd2d

Please sign in to comment.