Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion docs/generators/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES

<ul class="column-ul">
<li>BigDecimal</li>
<li>Boolean</li>
<li>Double</li>
<li>Float</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ public JavaClientCodegen() {
modelPackage = "org.openapitools.client.model";
rootJavaEEPackage = MICROPROFILE_REST_CLIENT_DEFAULT_ROOT_PACKAGE;

languageSpecificPrimitives.add("BigDecimal");

// cliOptions default redefinition need to be updated
updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage());
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
Expand Down Expand Up @@ -1023,16 +1021,6 @@ public CodegenModel fromModel(String name, Schema model) {
return codegenModel;
}

@Override
protected boolean needToImport(String type) {
// add import for BigDecimal explicitly since it is a primitive type
if("BigDecimal".equals(type)) {
return true;
}

return super.needToImport(type) && !type.contains(".");
}

@Override
public ModelsMap postProcessModelsEnum(ModelsMap objs) {
objs = super.postProcessModelsEnum(objs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
// deserialize {{{dataType}}}
try {
// validate the JSON object to see if any exception is thrown
{{#isNumber}}
if(!jsonElement.getAsJsonPrimitive().isNumber()) {
throw new IllegalArgumentException(String.format("Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString()));
}
actualAdapter = adapter{{{dataType}}};
{{/isNumber}}
{{^isNumber}}
{{#isPrimitiveType}}
if(!jsonElement.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) {
throw new IllegalArgumentException(String.format("Expected json element to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString()));
Expand All @@ -147,6 +154,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
actualAdapter = adapter{{{dataType}}};
{{/isArray}}
{{/isPrimitiveType}}
{{/isNumber}}
{{#isArray}}
if (!jsonElement.isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString()));
Expand All @@ -156,6 +164,13 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
// validate array items
for(JsonElement element : array) {
{{#items}}
{{#isNumber}}
if(!jsonElement.getAsJsonPrimitive().isNumber()) {
throw new IllegalArgumentException(String.format("Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString()));
}
actualAdapter = adapter{{{dataType}}};
{{/isNumber}}
{{^isNumber}}
{{#isPrimitiveType}}
if(!element.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) {
throw new IllegalArgumentException(String.format("Expected array items to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString()));
Expand All @@ -164,6 +179,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
{{^isPrimitiveType}}
{{{dataType}}}.validateJsonElement(element);
{{/isPrimitiveType}}
{{/isNumber}}
{{/items}}
}
actualAdapter = adapter{{{complexType}}}List;
Expand Down Expand Up @@ -311,6 +327,12 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
// validate the json string with {{{dataType}}}
try {
{{^hasVars}}
{{#isNumber}}
if(!jsonElement.getAsJsonPrimitive().isNumber()) {
throw new IllegalArgumentException(String.format("Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString()));
}
{{/isNumber}}
{{^isNumber}}
{{#isPrimitiveType}}
if(!jsonElement.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) {
throw new IllegalArgumentException(String.format("Expected json element to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString()));
Expand All @@ -321,6 +343,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
{{{dataType}}}.validateJsonElement(jsonElement);
{{/isArray}}
{{/isPrimitiveType}}
{{/isNumber}}
{{#isArray}}
if (!jsonElement.isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString()));
Expand All @@ -329,6 +352,12 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
// validate array items
for(JsonElement element : array) {
{{#items}}
{{#isNumber}}
if(!jsonElement.getAsJsonPrimitive().isNumber()) {
throw new IllegalArgumentException(String.format("Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString()));
}
{{/isNumber}}
{{^isNumber}}
{{#isPrimitiveType}}
if(!element.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) {
throw new IllegalArgumentException(String.format("Expected array items to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString()));
Expand All @@ -337,6 +366,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
{{^isPrimitiveType}}
{{{dataType}}}.validateJsonElement(element);
{{/isPrimitiveType}}
{{/isNumber}}
{{/items}}
}
{{/isArray}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public class Example {

### Return type

**BigDecimal**
[**BigDecimal**](BigDecimal.md)

### Authorization

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ public String toUrlQueryString(String prefix) {
// add `ArrayArrayNumber` to the URL query string
if (getArrayArrayNumber() != null) {
for (int i = 0; i < getArrayArrayNumber().size(); i++) {
try {
joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20")));
} catch (UnsupportedEncodingException e) {
// Should never happen, UTF-8 is always supported
throw new RuntimeException(e);
if (getArrayArrayNumber().get(i) != null) {
try {
joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20")));
} catch (UnsupportedEncodingException e) {
// Should never happen, UTF-8 is always supported
throw new RuntimeException(e);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ public String toUrlQueryString(String prefix) {
// add `ArrayNumber` to the URL query string
if (getArrayNumber() != null) {
for (int i = 0; i < getArrayNumber().size(); i++) {
try {
joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20")));
} catch (UnsupportedEncodingException e) {
// Should never happen, UTF-8 is always supported
throw new RuntimeException(e);
if (getArrayNumber().get(i) != null) {
try {
joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20")));
} catch (UnsupportedEncodingException e) {
// Should never happen, UTF-8 is always supported
throw new RuntimeException(e);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public class Example {

### Return type

**BigDecimal**
[**BigDecimal**](BigDecimal.md)

### Authorization

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/jersey1/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public class Example {

### Return type

**BigDecimal**
[**BigDecimal**](BigDecimal.md)

### Authorization

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public class Example {

### Return type

**BigDecimal**
[**BigDecimal**](BigDecimal.md)

### Authorization

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/jersey2-java8/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public class Example {

### Return type

**BigDecimal**
[**BigDecimal**](BigDecimal.md)

### Authorization

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/jersey3/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public class Example {

### Return type

**BigDecimal**
[**BigDecimal**](BigDecimal.md)

### Authorization

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/java/native-async/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ public class Example {

### Return type

CompletableFuture<**BigDecimal**>
CompletableFuture<[**BigDecimal**](BigDecimal.md)>


### Authorization
Expand Down Expand Up @@ -716,7 +716,7 @@ public class Example {

### Return type

CompletableFuture<ApiResponse<**BigDecimal**>>
CompletableFuture<ApiResponse<[**BigDecimal**](BigDecimal.md)>>


### Authorization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ public String toUrlQueryString(String prefix) {
// add `ArrayArrayNumber` to the URL query string
if (getArrayArrayNumber() != null) {
for (int i = 0; i < getArrayArrayNumber().size(); i++) {
joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
if (getArrayArrayNumber().get(i) != null) {
joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ public String toUrlQueryString(String prefix) {
// add `ArrayNumber` to the URL query string
if (getArrayNumber() != null) {
for (int i = 0; i < getArrayNumber().size(); i++) {
joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
if (getArrayNumber().get(i) != null) {
joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/java/native/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ public class Example {

### Return type

**BigDecimal**
[**BigDecimal**](BigDecimal.md)


### Authorization
Expand Down Expand Up @@ -671,7 +671,7 @@ public class Example {

### Return type

ApiResponse<**BigDecimal**>
ApiResponse<[**BigDecimal**](BigDecimal.md)>


### Authorization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ public String toUrlQueryString(String prefix) {
// add `ArrayArrayNumber` to the URL query string
if (getArrayArrayNumber() != null) {
for (int i = 0; i < getArrayArrayNumber().size(); i++) {
joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
if (getArrayArrayNumber().get(i) != null) {
joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ public String toUrlQueryString(String prefix) {
// add `ArrayNumber` to the URL query string
if (getArrayNumber() != null) {
for (int i = 0; i < getArrayNumber().size(); i++) {
joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
if (getArrayNumber().get(i) != null) {
joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public class Example {

### Return type

**BigDecimal**
[**BigDecimal**](BigDecimal.md)

### Authorization

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public class Example {

### Return type

**BigDecimal**
[**BigDecimal**](BigDecimal.md)

### Authorization

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ public void writeToParcel(Parcel out, int flags) {

AdditionalPropertiesClass(Parcel in) {
mapString = (Map<String, String>)in.readValue(null);
mapNumber = (Map<String, BigDecimal>)in.readValue(null);
mapNumber = (Map<String, BigDecimal>)in.readValue(BigDecimal.class.getClassLoader());
mapInteger = (Map<String, Integer>)in.readValue(null);
mapBoolean = (Map<String, Boolean>)in.readValue(null);
mapArrayInteger = (Map<String, List<Integer>>)in.readValue(List.class.getClassLoader());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void writeToParcel(Parcel out, int flags) {
}

ArrayOfNumberOnly(Parcel in) {
arrayNumber = (List<BigDecimal>)in.readValue(null);
arrayNumber = (List<BigDecimal>)in.readValue(BigDecimal.class.getClassLoader());
}

public int describeContents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public void writeToParcel(Parcel out, int flags) {
integer = (Integer)in.readValue(null);
int32 = (Integer)in.readValue(null);
int64 = (Long)in.readValue(null);
number = (BigDecimal)in.readValue(null);
number = (BigDecimal)in.readValue(BigDecimal.class.getClassLoader());
_float = (Float)in.readValue(null);
_double = (Double)in.readValue(null);
string = (String)in.readValue(null);
Expand All @@ -518,7 +518,7 @@ public void writeToParcel(Parcel out, int flags) {
dateTime = (OffsetDateTime)in.readValue(OffsetDateTime.class.getClassLoader());
uuid = (UUID)in.readValue(UUID.class.getClassLoader());
password = (String)in.readValue(null);
bigDecimal = (BigDecimal)in.readValue(null);
bigDecimal = (BigDecimal)in.readValue(BigDecimal.class.getClassLoader());
}

public int describeContents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void writeToParcel(Parcel out, int flags) {
}

NumberOnly(Parcel in) {
justNumber = (BigDecimal)in.readValue(null);
justNumber = (BigDecimal)in.readValue(BigDecimal.class.getClassLoader());
}

public int describeContents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void writeToParcel(Parcel out, int flags) {
}

OuterComposite(Parcel in) {
myNumber = (BigDecimal)in.readValue(null);
myNumber = (BigDecimal)in.readValue(BigDecimal.class.getClassLoader());
myString = (String)in.readValue(null);
myBoolean = (Boolean)in.readValue(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void writeToParcel(Parcel out, int flags) {

TypeHolderDefault(Parcel in) {
stringItem = (String)in.readValue(null);
numberItem = (BigDecimal)in.readValue(null);
numberItem = (BigDecimal)in.readValue(BigDecimal.class.getClassLoader());
integerItem = (Integer)in.readValue(null);
boolItem = (Boolean)in.readValue(null);
arrayItem = (List<Integer>)in.readValue(null);
Expand Down
Loading