[Java] Sync jersey2 jersey3 template (#18281)

* sync jersey2 and 3 templates

* add deprecated

* update samples
This commit is contained in:
William Cheng
2024-04-03 16:32:39 +08:00
committed by GitHub
parent 2934f5ac51
commit 88204b247a
27 changed files with 312 additions and 434 deletions

View File

@@ -981,7 +981,7 @@ public class ApiClient extends JavaTimeFormatter {
File file = (File) param.getValue();
FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey())
.fileName(file.getName()).size(file.length()).build();
// Attempt to probe the content type for the file so that the form part is more correctly
// and precisely identified, but fall back to application/octet-stream if that fails.
MediaType type;
@@ -990,7 +990,7 @@ public class ApiClient extends JavaTimeFormatter {
} catch (IOException | IllegalArgumentException e) {
type = MediaType.APPLICATION_OCTET_STREAM_TYPE;
}
multiPart.bodyPart(new FormDataBodyPart(contentDisp, file, type));
} else {
FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey()).build();

View File

@@ -45,12 +45,15 @@ public class ObjectWithDeprecatedFields {
private String uuid;
public static final String JSON_PROPERTY_ID = "id";
@Deprecated
private BigDecimal id;
public static final String JSON_PROPERTY_DEPRECATED_REF = "deprecatedRef";
@Deprecated
private DeprecatedObject deprecatedRef;
public static final String JSON_PROPERTY_BARS = "bars";
@Deprecated
private List<String> bars = new ArrayList<>();
public ObjectWithDeprecatedFields() {
@@ -81,6 +84,7 @@ public class ObjectWithDeprecatedFields {
}
@Deprecated
public ObjectWithDeprecatedFields id(BigDecimal id) {
this.id = id;
return this;
@@ -101,6 +105,7 @@ public class ObjectWithDeprecatedFields {
}
@Deprecated
@JsonProperty(JSON_PROPERTY_ID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setId(BigDecimal id) {
@@ -108,6 +113,7 @@ public class ObjectWithDeprecatedFields {
}
@Deprecated
public ObjectWithDeprecatedFields deprecatedRef(DeprecatedObject deprecatedRef) {
this.deprecatedRef = deprecatedRef;
return this;
@@ -128,6 +134,7 @@ public class ObjectWithDeprecatedFields {
}
@Deprecated
@JsonProperty(JSON_PROPERTY_DEPRECATED_REF)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setDeprecatedRef(DeprecatedObject deprecatedRef) {
@@ -135,6 +142,7 @@ public class ObjectWithDeprecatedFields {
}
@Deprecated
public ObjectWithDeprecatedFields bars(List<String> bars) {
this.bars = bars;
return this;
@@ -163,6 +171,7 @@ public class ObjectWithDeprecatedFields {
}
@Deprecated
@JsonProperty(JSON_PROPERTY_BARS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setBars(List<String> bars) {