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
Original file line number Diff line number Diff line change
Expand Up @@ -1359,20 +1359,20 @@ public String toDefaultValue(CodegenProperty cp, Schema schema) {

return String.format(Locale.ROOT, "new %s<>()",
instantiationTypes().getOrDefault("map", "HashMap"));
} else if (ModelUtils.isIntegerSchema(schema)) {
} else if (ModelUtils.isIntegerSchema(schema) || cp.isInteger || cp.isLong) {
if (schema.getDefault() != null) {
if (SchemaTypeUtil.INTEGER64_FORMAT.equals(schema.getFormat())) {
if (SchemaTypeUtil.INTEGER64_FORMAT.equals(schema.getFormat()) || cp.isLong) {
return schema.getDefault().toString() + "l";
} else {
return schema.getDefault().toString();
}
}
return null;
} else if (ModelUtils.isNumberSchema(schema)) {
} else if (ModelUtils.isNumberSchema(schema) || cp.isFloat || cp.isDouble) {
if (schema.getDefault() != null) {
if (SchemaTypeUtil.FLOAT_FORMAT.equals(schema.getFormat())) {
if (SchemaTypeUtil.FLOAT_FORMAT.equals(schema.getFormat()) || cp.isFloat) {
return schema.getDefault().toString() + "f";
} else if (SchemaTypeUtil.DOUBLE_FORMAT.equals(schema.getFormat())) {
} else if (SchemaTypeUtil.DOUBLE_FORMAT.equals(schema.getFormat()) || cp.isDouble) {
return schema.getDefault().toString() + "d";
} else {
return "new BigDecimal(\"" + schema.getDefault().toString() + "\")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2240,3 +2240,39 @@ components:
deprecated: true
items:
$ref: '#/components/schemas/Bar'
LongId:
description: "Id as long"
type: integer
format: int64
Weight:
description: "Weight as float"
format: float
type: number
Height:
description: "Height as double"
format: double
type: number
AllOfRefToLong:
description: "Object with allOf ref to long"
type: object
properties:
id:
allOf:
- $ref: '#/components/schemas/LongId'
default: 10
AllOfRefToFloat:
description: "Object with allOf ref to float"
type: object
properties:
weight:
allOf:
- $ref: '#/components/schemas/Weight'
default: 7.89
AllOfRefToDouble:
description: "Object with allOf ref to double"
type: object
properties:
height:
allOf:
- $ref: '#/components/schemas/Height'
default: 32.1
Original file line number Diff line number Diff line change
Expand Up @@ -2830,3 +2830,39 @@ components:
[ "h3", "Header 3" ],
[ "h4", "Header 4" ]
]
LongId:
description: "Id as long"
type: integer
format: int64
Weight:
description: "Weight as float"
format: float
type: number
Height:
description: "Height as double"
format: double
type: number
AllOfRefToLong:
description: "Object with allOf ref to long"
type: object
properties:
id:
allOf:
- $ref: '#/components/schemas/LongId'
default: 10
AllOfRefToFloat:
description: "Object with allOf ref to float"
type: object
properties:
weight:
allOf:
- $ref: '#/components/schemas/Weight'
default: 7.89
AllOfRefToDouble:
description: "Object with allOf ref to double"
type: object
properties:
height:
allOf:
- $ref: '#/components/schemas/Height'
default: 32.1
Original file line number Diff line number Diff line change
Expand Up @@ -2231,3 +2231,39 @@ components:
deprecated: true
items:
$ref: '#/components/schemas/Bar'
LongId:
description: "Id as long"
type: integer
format: int64
Weight:
description: "Weight as float"
format: float
type: number
Height:
description: "Height as double"
format: double
type: number
AllOfRefToLong:
description: "Object with allOf ref to long"
type: object
properties:
id:
allOf:
- $ref: '#/components/schemas/LongId'
default: 10
AllOfRefToFloat:
description: "Object with allOf ref to float"
type: object
properties:
weight:
allOf:
- $ref: '#/components/schemas/Weight'
default: 7.89
AllOfRefToDouble:
description: "Object with allOf ref to double"
type: object
properties:
height:
allOf:
- $ref: '#/components/schemas/Height'
default: 32.1
9 changes: 9 additions & 0 deletions samples/client/petstore/java/jersey3/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ api/openapi.yaml
build.gradle
build.sbt
docs/AdditionalPropertiesClass.md
docs/AllOfRefToDouble.md
docs/AllOfRefToFloat.md
docs/AllOfRefToLong.md
docs/Animal.md
docs/AnotherFakeApi.md
docs/Apple.md
Expand Down Expand Up @@ -125,6 +128,9 @@ src/main/java/org/openapitools/client/auth/OAuth.java
src/main/java/org/openapitools/client/auth/OAuthFlow.java
src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
src/main/java/org/openapitools/client/model/AllOfRefToDouble.java
src/main/java/org/openapitools/client/model/AllOfRefToFloat.java
src/main/java/org/openapitools/client/model/AllOfRefToLong.java
src/main/java/org/openapitools/client/model/Animal.java
src/main/java/org/openapitools/client/model/Apple.java
src/main/java/org/openapitools/client/model/AppleReq.java
Expand Down Expand Up @@ -199,3 +205,6 @@ src/main/java/org/openapitools/client/model/TriangleInterface.java
src/main/java/org/openapitools/client/model/User.java
src/main/java/org/openapitools/client/model/Whale.java
src/main/java/org/openapitools/client/model/Zebra.java
src/test/java/org/openapitools/client/model/AllOfRefToDoubleTest.java
src/test/java/org/openapitools/client/model/AllOfRefToFloatTest.java
src/test/java/org/openapitools/client/model/AllOfRefToLongTest.java
3 changes: 3 additions & 0 deletions samples/client/petstore/java/jersey3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ Class | Method | HTTP request | Description
## Documentation for Models

- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [AllOfRefToDouble](docs/AllOfRefToDouble.md)
- [AllOfRefToFloat](docs/AllOfRefToFloat.md)
- [AllOfRefToLong](docs/AllOfRefToLong.md)
- [Animal](docs/Animal.md)
- [Apple](docs/Apple.md)
- [AppleReq](docs/AppleReq.md)
Expand Down
36 changes: 36 additions & 0 deletions samples/client/petstore/java/jersey3/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2293,6 +2293,42 @@ components:
$ref: "#/components/schemas/Bar"
type: array
type: object
LongId:
description: Id as long
format: int64
type: integer
Weight:
description: Weight as float
format: float
type: number
Height:
description: Height as double
format: double
type: number
AllOfRefToLong:
description: Object with allOf ref to long
properties:
id:
allOf:
- $ref: "#/components/schemas/LongId"
default: 10
type: object
AllOfRefToFloat:
description: Object with allOf ref to float
properties:
weight:
allOf:
- $ref: "#/components/schemas/Weight"
default: 7.89
type: object
AllOfRefToDouble:
description: Object with allOf ref to double
properties:
height:
allOf:
- $ref: "#/components/schemas/Height"
default: 32.1
type: object
_foo_get_default_response:
example:
string:
Expand Down
14 changes: 14 additions & 0 deletions samples/client/petstore/java/jersey3/docs/AllOfRefToDouble.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# AllOfRefToDouble

Object with allOf ref to double

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**height** | **Double** | Height as double | [optional] |



14 changes: 14 additions & 0 deletions samples/client/petstore/java/jersey3/docs/AllOfRefToFloat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# AllOfRefToFloat

Object with allOf ref to float

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**weight** | **Float** | Weight as float | [optional] |



14 changes: 14 additions & 0 deletions samples/client/petstore/java/jersey3/docs/AllOfRefToLong.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# AllOfRefToLong

Object with allOf ref to long

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**id** | **Long** | Id as long | [optional] |



Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


package org.openapitools.client.model;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import java.util.Objects;
import java.util.Map;
import java.util.HashMap;
import java.util.Locale;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import jakarta.validation.constraints.*;
import jakarta.validation.Valid;
import org.openapitools.client.JSON;


/**
* Object with allOf ref to double
*/
@JsonPropertyOrder({
AllOfRefToDouble.JSON_PROPERTY_HEIGHT
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0-SNAPSHOT")
public class AllOfRefToDouble {
public static final String JSON_PROPERTY_HEIGHT = "height";
@jakarta.annotation.Nullable
private Double height = 32.1d;

public AllOfRefToDouble() {
}

public AllOfRefToDouble height(@jakarta.annotation.Nullable Double height) {
this.height = height;
return this;
}

/**
* Height as double
* @return height
*/
@jakarta.annotation.Nullable

@JsonProperty(value = JSON_PROPERTY_HEIGHT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Double getHeight() {
return height;
}


@JsonProperty(value = JSON_PROPERTY_HEIGHT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setHeight(@jakarta.annotation.Nullable Double height) {
this.height = height;
}


/**
* Return true if this AllOfRefToDouble object is equal to o.
*/
@Override
public boolean equals(Object o) {
return EqualsBuilder.reflectionEquals(this, o, false, null, true);
}

@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class AllOfRefToDouble {\n");
sb.append(" height: ").append(toIndentedString(height)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}

}

Loading
Loading