Skip to content

Commit

Permalink
(java, fix): file upload endpoints compile when determining mime type (
Browse files Browse the repository at this point in the history
…#3027)

* (fix): file upload test definition doesn't contain crazy undsicriminated unions

* fix java-model seed.yml
  • Loading branch information
dsinghvi authored Feb 21, 2024
1 parent 77954c8 commit d938128
Show file tree
Hide file tree
Showing 40 changed files with 61 additions and 1,525 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.

3 changes: 1 addition & 2 deletions seed/java-model/seed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ allowedFailures:
- extends
- reserved-keywords
- trace
- file-upload
- undiscriminated-unions.
- undiscriminated-unions
Loading

0 comments on commit d938128

Please sign in to comment.