add support for union of strictfloat and strictint (#15124)

This commit is contained in:
William Cheng 2023-04-06 11:51:12 +08:00 committed by GitHub
parent b409ceb3a0
commit 07227d4650
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 1530 additions and 34 deletions

View File

@ -5,4 +5,4 @@ templateDir: modules/openapi-generator/src/main/resources/python-nextgen
library: asyncio
additionalProperties:
packageName: petstore_api
floatStrictType: false
mapNumberTo: float

View File

@ -6,3 +6,4 @@ additionalProperties:
packageName: petstore_api
useOneOfDiscriminatorLookup: "true"
disallowAdditionalPropertiesIfNotPresent: false
mapNumberTo: StrictFloat

View File

@ -22,10 +22,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|dateFormat|date format for query parameters| |%Y-%m-%d|
|datetimeFormat|datetime format for query parameters| |%Y-%m-%dT%H:%M:%S%z|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|floatStrictType|Use strict type for float, i.e. StrictFloat or confloat(strict=true, ...)| |true|
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|library|library template (sub-template) to use: asyncio, tornado (deprecated), urllib3| |urllib3|
|mapNumberTo|Map number to Union[StrictFloat, StrictInt], StrictStr or float.| |Union[StrictFloat, StrictInt]|
|packageName|python package name (convention: snake_case).| |openapi_client|
|packageUrl|python package URL.| |null|
|packageVersion|python package version.| |1.0.0|

View File

@ -47,18 +47,18 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
public static final String PACKAGE_URL = "packageUrl";
public static final String DEFAULT_LIBRARY = "urllib3";
public static final String RECURSION_LIMIT = "recursionLimit";
public static final String FLOAT_STRICT_TYPE = "floatStrictType";
public static final String DATETIME_FORMAT = "datetimeFormat";
public static final String DATE_FORMAT = "dateFormat";
public static final String MAP_NUMBER_TO = "mapNumberTo";
protected String packageUrl;
protected String apiDocPath = "docs" + File.separator;
protected String modelDocPath = "docs" + File.separator;
protected boolean hasModelsToImport = Boolean.FALSE;
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
protected boolean floatStrictType = true;
protected String datetimeFormat = "%Y-%m-%dT%H:%M:%S.%f%z";
protected String dateFormat = "%Y-%m-%d";
protected String mapNumberTo = "Union[StrictFloat, StrictInt]";
protected Map<Character, String> regexModifiers;
@ -177,8 +177,8 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
cliOptions.add(new CliOption(CodegenConstants.SOURCECODEONLY_GENERATION, CodegenConstants.SOURCECODEONLY_GENERATION_DESC)
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(RECURSION_LIMIT, "Set the recursion limit. If not set, use the system default value."));
cliOptions.add(new CliOption(FLOAT_STRICT_TYPE, "Use strict type for float, i.e. StrictFloat or confloat(strict=true, ...)")
.defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(MAP_NUMBER_TO, "Map number to Union[StrictFloat, StrictInt], StrictStr or float.")
.defaultValue("Union[StrictFloat, StrictInt]"));
cliOptions.add(new CliOption(DATETIME_FORMAT, "datetime format for query parameters")
.defaultValue("%Y-%m-%dT%H:%M:%S%z"));
cliOptions.add(new CliOption(DATE_FORMAT, "date format for query parameters")
@ -281,8 +281,8 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
additionalProperties.put(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, useOneOfDiscriminatorLookup);
}
if (additionalProperties.containsKey(FLOAT_STRICT_TYPE)) {
setFloatStrictType(convertPropertyToBooleanAndWriteBack(FLOAT_STRICT_TYPE));
if (additionalProperties.containsKey(MAP_NUMBER_TO)) {
setMapNumberTo(String.valueOf(additionalProperties.get(MAP_NUMBER_TO)));
}
if (additionalProperties.containsKey(DATETIME_FORMAT)) {
@ -478,34 +478,59 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
} else if (cp.isNumber || cp.isFloat || cp.isDouble) {
if (cp.hasValidation) {
List<String> fieldCustomization = new ArrayList<>();
List<String> intFieldCustomization = new ArrayList<>();
// e.g. confloat(ge=10, le=100, strict=True)
if (cp.getMaximum() != null) {
if (cp.getExclusiveMaximum()) {
fieldCustomization.add("gt=" + cp.getMaximum());
fieldCustomization.add("lt=" + cp.getMaximum());
intFieldCustomization.add("lt=" + Math.ceil(Double.valueOf(cp.getMaximum()))); // e.g. < 7.59 becomes < 8
} else {
fieldCustomization.add("ge=" + cp.getMaximum());
fieldCustomization.add("le=" + cp.getMaximum());
intFieldCustomization.add("le=" + Math.floor(Double.valueOf(cp.getMaximum()))); // e.g. <= 7.59 becomes <= 7
}
}
if (cp.getMinimum() != null) {
if (cp.getExclusiveMinimum()) {
fieldCustomization.add("lt=" + cp.getMinimum());
fieldCustomization.add("gt=" + cp.getMinimum());
intFieldCustomization.add("gt=" + Math.floor(Double.valueOf(cp.getMinimum()))); // e.g. > 7.59 becomes > 7
} else {
fieldCustomization.add("le=" + cp.getMinimum());
fieldCustomization.add("ge=" + cp.getMinimum());
intFieldCustomization.add("ge=" + Math.ceil(Double.valueOf(cp.getMinimum()))); // e.g. >= 7.59 becomes >= 8
}
}
if (cp.getMultipleOf() != null) {
fieldCustomization.add("multiple_of=" + cp.getMultipleOf());
}
if (floatStrictType) {
if ("Union[StrictFloat, StrictInt]".equals(mapNumberTo)) {
fieldCustomization.add("strict=True");
intFieldCustomization.add("strict=True");
pydanticImports.add("confloat");
pydanticImports.add("conint");
typingImports.add("Union");
return String.format(Locale.ROOT, "Union[%s(%s), %s(%s)]", "confloat",
StringUtils.join(fieldCustomization, ", "),
"conint",
StringUtils.join(intFieldCustomization, ", ")
);
} else if ("StrictFloat".equals(mapNumberTo)) {
fieldCustomization.add("strict=True");
pydanticImports.add("confloat");
return String.format(Locale.ROOT, "%s(%s)", "confloat",
StringUtils.join(fieldCustomization, ", "));
} else { // float
pydanticImports.add("confloat");
return String.format(Locale.ROOT, "%s(%s)", "confloat",
StringUtils.join(fieldCustomization, ", "));
}
pydanticImports.add("confloat");
return String.format(Locale.ROOT, "%s(%s)", "confloat",
StringUtils.join(fieldCustomization, ", "));
} else {
if (floatStrictType) {
if ("Union[StrictFloat, StrictInt]".equals(mapNumberTo)) {
typingImports.add("Union");
pydanticImports.add("StrictFloat");
pydanticImports.add("StrictInt");
return "Union[StrictFloat, StrictInt]";
} else if ("StrictFloat".equals(mapNumberTo)) {
pydanticImports.add("StrictFloat");
return "StrictFloat";
} else {
@ -723,34 +748,59 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
} else if (cp.isNumber || cp.isFloat || cp.isDouble) {
if (cp.hasValidation) {
List<String> fieldCustomization = new ArrayList<>();
List<String> intFieldCustomization = new ArrayList<>();
// e.g. confloat(ge=10, le=100, strict=True)
if (cp.getMaximum() != null) {
if (cp.getExclusiveMaximum()) {
fieldCustomization.add("lt=" + cp.getMaximum());
intFieldCustomization.add("lt=" + (int) Math.ceil(Double.valueOf(cp.getMaximum()))); // e.g. < 7.59 => < 8
} else {
fieldCustomization.add("le=" + cp.getMaximum());
intFieldCustomization.add("le=" + (int) Math.floor(Double.valueOf(cp.getMaximum()))); // e.g. <= 7.59 => <= 7
}
}
if (cp.getMinimum() != null) {
if (cp.getExclusiveMinimum()) {
fieldCustomization.add("gt=" + cp.getMinimum());
intFieldCustomization.add("gt=" + (int) Math.floor(Double.valueOf(cp.getMinimum()))); // e.g. > 7.59 => > 7
} else {
fieldCustomization.add("ge=" + cp.getMinimum());
intFieldCustomization.add("ge=" + (int) Math.ceil(Double.valueOf(cp.getMinimum()))); // e.g. >= 7.59 => >= 8
}
}
if (cp.getMultipleOf() != null) {
fieldCustomization.add("multiple_of=" + cp.getMultipleOf());
}
if (floatStrictType) {
if ("Union[StrictFloat, StrictInt]".equals(mapNumberTo)) {
fieldCustomization.add("strict=True");
intFieldCustomization.add("strict=True");
pydanticImports.add("confloat");
pydanticImports.add("conint");
typingImports.add("Union");
return String.format(Locale.ROOT, "Union[%s(%s), %s(%s)]", "confloat",
StringUtils.join(fieldCustomization, ", "),
"conint",
StringUtils.join(intFieldCustomization, ", ")
);
} else if ("StrictFloat".equals(mapNumberTo)) {
fieldCustomization.add("strict=True");
pydanticImports.add("confloat");
return String.format(Locale.ROOT, "%s(%s)", "confloat",
StringUtils.join(fieldCustomization, ", "));
} else { // float
pydanticImports.add("confloat");
return String.format(Locale.ROOT, "%s(%s)", "confloat",
StringUtils.join(fieldCustomization, ", "));
}
pydanticImports.add("confloat");
return String.format(Locale.ROOT, "%s(%s)", "confloat",
StringUtils.join(fieldCustomization, ", "));
} else {
if (floatStrictType) {
if ("Union[StrictFloat, StrictInt]".equals(mapNumberTo)) {
typingImports.add("Union");
pydanticImports.add("StrictFloat");
pydanticImports.add("StrictInt");
return "Union[StrictFloat, StrictInt]";
} else if ("StrictFloat".equals(mapNumberTo)) {
pydanticImports.add("StrictFloat");
return "StrictFloat";
} else {
@ -1334,8 +1384,8 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
}
}
vendorExtensions.put("x-regex", regex.replace("\"","\\\""));
vendorExtensions.put("x-pattern", pattern.replace("\"","\\\""));
vendorExtensions.put("x-regex", regex.replace("\"", "\\\""));
vendorExtensions.put("x-pattern", pattern.replace("\"", "\\\""));
vendorExtensions.put("x-modifiers", modifiers);
}
}
@ -1529,8 +1579,14 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
return "var_" + name;
}
public void setFloatStrictType(boolean floatStrictType) {
this.floatStrictType = floatStrictType;
public void setMapNumberTo(String mapNumberTo) {
if ("Union[StrictFloat, StrictInt]".equals(mapNumberTo)
|| "StrictFloat".equals(mapNumberTo)
|| "float".equals(mapNumberTo)) {
this.mapNumberTo = mapNumberTo;
} else {
throw new IllegalArgumentException("mapNumberTo value must be Union[StrictFloat, StrictInt], StrictStr or float");
}
}
public void setDatetimeFormat(String datetimeFormat) {

View File

@ -516,3 +516,16 @@ components:
format: date-time
description: A date
- $ref: '#/components/schemas/Query'
NumberPropertiesOnly:
type: object
properties:
number:
type: number
float:
type: number
format: float
double:
type: number
format: double
minimum: 0.8
maximum: 50.2

View File

@ -13,6 +13,7 @@ docs/DataQueryAllOf.md
docs/DefaultValue.md
docs/FormApi.md
docs/HeaderApi.md
docs/NumberPropertiesOnly.md
docs/PathApi.md
docs/Pet.md
docs/Query.md
@ -53,6 +54,7 @@ src/main/java/org/openapitools/client/model/Category.java
src/main/java/org/openapitools/client/model/DataQuery.java
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
src/main/java/org/openapitools/client/model/DefaultValue.java
src/main/java/org/openapitools/client/model/NumberPropertiesOnly.java
src/main/java/org/openapitools/client/model/Pet.java
src/main/java/org/openapitools/client/model/Query.java
src/main/java/org/openapitools/client/model/StringEnumRef.java

View File

@ -127,6 +127,7 @@ Class | Method | HTTP request | Description
- [DataQuery](docs/DataQuery.md)
- [DataQueryAllOf](docs/DataQueryAllOf.md)
- [DefaultValue](docs/DefaultValue.md)
- [NumberPropertiesOnly](docs/NumberPropertiesOnly.md)
- [Pet](docs/Pet.md)
- [Query](docs/Query.md)
- [StringEnumRef](docs/StringEnumRef.md)

View File

@ -521,6 +521,19 @@ components:
allOf:
- $ref: '#/components/schemas/DataQuery_allOf'
- $ref: '#/components/schemas/Query'
NumberPropertiesOnly:
properties:
number:
type: number
float:
format: float
type: number
double:
format: double
maximum: 50.2
minimum: 0.8
type: number
type: object
test_form_integer_boolean_string_request:
properties:
integer_form:

View File

@ -0,0 +1,15 @@
# NumberPropertiesOnly
## Properties
| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**number** | **BigDecimal** | | [optional] |
|**_float** | **Float** | | [optional] |
|**_double** | **Double** | | [optional] |

View File

@ -0,0 +1,238 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* 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 java.util.Objects;
import java.util.Arrays;
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.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.StringJoiner;
/**
* NumberPropertiesOnly
*/
@JsonPropertyOrder({
NumberPropertiesOnly.JSON_PROPERTY_NUMBER,
NumberPropertiesOnly.JSON_PROPERTY_FLOAT,
NumberPropertiesOnly.JSON_PROPERTY_DOUBLE
})
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class NumberPropertiesOnly {
public static final String JSON_PROPERTY_NUMBER = "number";
private BigDecimal number;
public static final String JSON_PROPERTY_FLOAT = "float";
private Float _float;
public static final String JSON_PROPERTY_DOUBLE = "double";
private Double _double;
public NumberPropertiesOnly() {
}
public NumberPropertiesOnly number(BigDecimal number) {
this.number = number;
return this;
}
/**
* Get number
* @return number
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public BigDecimal getNumber() {
return number;
}
@JsonProperty(JSON_PROPERTY_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setNumber(BigDecimal number) {
this.number = number;
}
public NumberPropertiesOnly _float(Float _float) {
this._float = _float;
return this;
}
/**
* Get _float
* @return _float
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_FLOAT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Float getFloat() {
return _float;
}
@JsonProperty(JSON_PROPERTY_FLOAT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setFloat(Float _float) {
this._float = _float;
}
public NumberPropertiesOnly _double(Double _double) {
this._double = _double;
return this;
}
/**
* Get _double
* minimum: 0.8
* maximum: 50.2
* @return _double
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_DOUBLE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Double getDouble() {
return _double;
}
@JsonProperty(JSON_PROPERTY_DOUBLE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setDouble(Double _double) {
this._double = _double;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
NumberPropertiesOnly numberPropertiesOnly = (NumberPropertiesOnly) o;
return Objects.equals(this.number, numberPropertiesOnly.number) &&
Objects.equals(this._float, numberPropertiesOnly._float) &&
Objects.equals(this._double, numberPropertiesOnly._double);
}
@Override
public int hashCode() {
return Objects.hash(number, _float, _double);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class NumberPropertiesOnly {\n");
sb.append(" number: ").append(toIndentedString(number)).append("\n");
sb.append(" _float: ").append(toIndentedString(_float)).append("\n");
sb.append(" _double: ").append(toIndentedString(_double)).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 ");
}
/**
* Convert the instance into URL query string.
*
* @return URL query string
*/
public String toUrlQueryString() {
return toUrlQueryString(null);
}
/**
* Convert the instance into URL query string.
*
* @param prefix prefix of the query string
* @return URL query string
*/
public String toUrlQueryString(String prefix) {
String suffix = "";
String containerSuffix = "";
String containerPrefix = "";
if (prefix == null) {
// style=form, explode=true, e.g. /pet?name=cat&type=manx
prefix = "";
} else {
// deepObject style e.g. /pet?id[name]=cat&id[type]=manx
prefix = prefix + "[";
suffix = "]";
containerSuffix = "]";
containerPrefix = "[";
}
StringJoiner joiner = new StringJoiner("&");
// add `number` to the URL query string
if (getNumber() != null) {
try {
joiner.add(String.format("%snumber%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNumber()), "UTF-8").replaceAll("\\+", "%20")));
} catch (UnsupportedEncodingException e) {
// Should never happen, UTF-8 is always supported
throw new RuntimeException(e);
}
}
// add `float` to the URL query string
if (getFloat() != null) {
try {
joiner.add(String.format("%sfloat%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFloat()), "UTF-8").replaceAll("\\+", "%20")));
} catch (UnsupportedEncodingException e) {
// Should never happen, UTF-8 is always supported
throw new RuntimeException(e);
}
}
// add `double` to the URL query string
if (getDouble() != null) {
try {
joiner.add(String.format("%sdouble%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDouble()), "UTF-8").replaceAll("\\+", "%20")));
} catch (UnsupportedEncodingException e) {
// Should never happen, UTF-8 is always supported
throw new RuntimeException(e);
}
}
return joiner.toString();
}
}

View File

@ -0,0 +1,65 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* 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 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.math.BigDecimal;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
/**
* Model tests for NumberPropertiesOnly
*/
public class NumberPropertiesOnlyTest {
private final NumberPropertiesOnly model = new NumberPropertiesOnly();
/**
* Model tests for NumberPropertiesOnly
*/
@Test
public void testNumberPropertiesOnly() {
// TODO: test NumberPropertiesOnly
}
/**
* Test the property 'number'
*/
@Test
public void numberTest() {
// TODO: test number
}
/**
* Test the property '_float'
*/
@Test
public void _floatTest() {
// TODO: test _float
}
/**
* Test the property '_double'
*/
@Test
public void _doubleTest() {
// TODO: test _double
}
}

View File

@ -33,6 +33,7 @@ src/main/java/org/openapitools/client/model/Category.java
src/main/java/org/openapitools/client/model/DataQuery.java
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
src/main/java/org/openapitools/client/model/DefaultValue.java
src/main/java/org/openapitools/client/model/NumberPropertiesOnly.java
src/main/java/org/openapitools/client/model/Pet.java
src/main/java/org/openapitools/client/model/Query.java
src/main/java/org/openapitools/client/model/StringEnumRef.java

View File

@ -521,6 +521,19 @@ components:
allOf:
- $ref: '#/components/schemas/DataQuery_allOf'
- $ref: '#/components/schemas/Query'
NumberPropertiesOnly:
properties:
number:
type: number
float:
format: float
type: number
double:
format: double
maximum: 50.2
minimum: 0.8
type: number
type: object
test_form_integer_boolean_string_request:
properties:
integer_form:

View File

@ -0,0 +1,155 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* 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 java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.math.BigDecimal;
/**
* NumberPropertiesOnly
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class NumberPropertiesOnly {
public static final String SERIALIZED_NAME_NUMBER = "number";
@SerializedName(SERIALIZED_NAME_NUMBER)
private BigDecimal number;
public static final String SERIALIZED_NAME_FLOAT = "float";
@SerializedName(SERIALIZED_NAME_FLOAT)
private Float _float;
public static final String SERIALIZED_NAME_DOUBLE = "double";
@SerializedName(SERIALIZED_NAME_DOUBLE)
private Double _double;
public NumberPropertiesOnly() {
}
public NumberPropertiesOnly number(BigDecimal number) {
this.number = number;
return this;
}
/**
* Get number
* @return number
**/
@javax.annotation.Nullable
public BigDecimal getNumber() {
return number;
}
public void setNumber(BigDecimal number) {
this.number = number;
}
public NumberPropertiesOnly _float(Float _float) {
this._float = _float;
return this;
}
/**
* Get _float
* @return _float
**/
@javax.annotation.Nullable
public Float getFloat() {
return _float;
}
public void setFloat(Float _float) {
this._float = _float;
}
public NumberPropertiesOnly _double(Double _double) {
this._double = _double;
return this;
}
/**
* Get _double
* minimum: 0.8
* maximum: 50.2
* @return _double
**/
@javax.annotation.Nullable
public Double getDouble() {
return _double;
}
public void setDouble(Double _double) {
this._double = _double;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
NumberPropertiesOnly numberPropertiesOnly = (NumberPropertiesOnly) o;
return Objects.equals(this.number, numberPropertiesOnly.number) &&
Objects.equals(this._float, numberPropertiesOnly._float) &&
Objects.equals(this._double, numberPropertiesOnly._double);
}
@Override
public int hashCode() {
return Objects.hash(number, _float, _double);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class NumberPropertiesOnly {\n");
sb.append(" number: ").append(toIndentedString(number)).append("\n");
sb.append(" _float: ").append(toIndentedString(_float)).append("\n");
sb.append(" _double: ").append(toIndentedString(_double)).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 ");
}
}

View File

@ -0,0 +1,64 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* 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 com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.math.BigDecimal;
import org.junit.jupiter.api.Test;
/**
* Model tests for NumberPropertiesOnly
*/
class NumberPropertiesOnlyTest {
private final NumberPropertiesOnly model = new NumberPropertiesOnly();
/**
* Model tests for NumberPropertiesOnly
*/
@Test
void testNumberPropertiesOnly() {
// TODO: test NumberPropertiesOnly
}
/**
* Test the property 'number'
*/
@Test
void numberTest() {
// TODO: test number
}
/**
* Test the property '_float'
*/
@Test
void _floatTest() {
// TODO: test _float
}
/**
* Test the property '_double'
*/
@Test
void _doubleTest() {
// TODO: test _double
}
}

View File

@ -13,6 +13,7 @@ docs/DataQueryAllOf.md
docs/DefaultValue.md
docs/FormApi.md
docs/HeaderApi.md
docs/NumberPropertiesOnly.md
docs/PathApi.md
docs/Pet.md
docs/Query.md
@ -50,6 +51,7 @@ src/main/java/org/openapitools/client/model/Category.java
src/main/java/org/openapitools/client/model/DataQuery.java
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
src/main/java/org/openapitools/client/model/DefaultValue.java
src/main/java/org/openapitools/client/model/NumberPropertiesOnly.java
src/main/java/org/openapitools/client/model/Pet.java
src/main/java/org/openapitools/client/model/Query.java
src/main/java/org/openapitools/client/model/StringEnumRef.java

View File

@ -139,6 +139,7 @@ Class | Method | HTTP request | Description
- [DataQuery](docs/DataQuery.md)
- [DataQueryAllOf](docs/DataQueryAllOf.md)
- [DefaultValue](docs/DefaultValue.md)
- [NumberPropertiesOnly](docs/NumberPropertiesOnly.md)
- [Pet](docs/Pet.md)
- [Query](docs/Query.md)
- [StringEnumRef](docs/StringEnumRef.md)

View File

@ -521,6 +521,19 @@ components:
allOf:
- $ref: '#/components/schemas/DataQuery_allOf'
- $ref: '#/components/schemas/Query'
NumberPropertiesOnly:
properties:
number:
type: number
float:
format: float
type: number
double:
format: double
maximum: 50.2
minimum: 0.8
type: number
type: object
test_form_integer_boolean_string_request:
properties:
integer_form:

View File

@ -0,0 +1,15 @@
# NumberPropertiesOnly
## Properties
| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**number** | **BigDecimal** | | [optional] |
|**_float** | **Float** | | [optional] |
|**_double** | **Double** | | [optional] |

View File

@ -0,0 +1,225 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* 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 java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.StringJoiner;
import java.util.Objects;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
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.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
/**
* NumberPropertiesOnly
*/
@JsonPropertyOrder({
NumberPropertiesOnly.JSON_PROPERTY_NUMBER,
NumberPropertiesOnly.JSON_PROPERTY_FLOAT,
NumberPropertiesOnly.JSON_PROPERTY_DOUBLE
})
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class NumberPropertiesOnly {
public static final String JSON_PROPERTY_NUMBER = "number";
private BigDecimal number;
public static final String JSON_PROPERTY_FLOAT = "float";
private Float _float;
public static final String JSON_PROPERTY_DOUBLE = "double";
private Double _double;
public NumberPropertiesOnly() {
}
public NumberPropertiesOnly number(BigDecimal number) {
this.number = number;
return this;
}
/**
* Get number
* @return number
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public BigDecimal getNumber() {
return number;
}
@JsonProperty(JSON_PROPERTY_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setNumber(BigDecimal number) {
this.number = number;
}
public NumberPropertiesOnly _float(Float _float) {
this._float = _float;
return this;
}
/**
* Get _float
* @return _float
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_FLOAT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Float getFloat() {
return _float;
}
@JsonProperty(JSON_PROPERTY_FLOAT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setFloat(Float _float) {
this._float = _float;
}
public NumberPropertiesOnly _double(Double _double) {
this._double = _double;
return this;
}
/**
* Get _double
* minimum: 0.8
* maximum: 50.2
* @return _double
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_DOUBLE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Double getDouble() {
return _double;
}
@JsonProperty(JSON_PROPERTY_DOUBLE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setDouble(Double _double) {
this._double = _double;
}
/**
* Return true if this NumberPropertiesOnly object is equal to o.
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
NumberPropertiesOnly numberPropertiesOnly = (NumberPropertiesOnly) o;
return Objects.equals(this.number, numberPropertiesOnly.number) &&
Objects.equals(this._float, numberPropertiesOnly._float) &&
Objects.equals(this._double, numberPropertiesOnly._double);
}
@Override
public int hashCode() {
return Objects.hash(number, _float, _double);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class NumberPropertiesOnly {\n");
sb.append(" number: ").append(toIndentedString(number)).append("\n");
sb.append(" _float: ").append(toIndentedString(_float)).append("\n");
sb.append(" _double: ").append(toIndentedString(_double)).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 ");
}
/**
* Convert the instance into URL query string.
*
* @return URL query string
*/
public String toUrlQueryString() {
return toUrlQueryString(null);
}
/**
* Convert the instance into URL query string.
*
* @param prefix prefix of the query string
* @return URL query string
*/
public String toUrlQueryString(String prefix) {
String suffix = "";
String containerSuffix = "";
String containerPrefix = "";
if (prefix == null) {
// style=form, explode=true, e.g. /pet?name=cat&type=manx
prefix = "";
} else {
// deepObject style e.g. /pet?id[name]=cat&id[type]=manx
prefix = prefix + "[";
suffix = "]";
containerSuffix = "]";
containerPrefix = "[";
}
StringJoiner joiner = new StringJoiner("&");
// add `number` to the URL query string
if (getNumber() != null) {
joiner.add(String.format("%snumber%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
// add `float` to the URL query string
if (getFloat() != null) {
joiner.add(String.format("%sfloat%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFloat()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
// add `double` to the URL query string
if (getDouble() != null) {
joiner.add(String.format("%sdouble%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDouble()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
return joiner.toString();
}
}

View File

@ -0,0 +1,65 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* 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 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.math.BigDecimal;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
/**
* Model tests for NumberPropertiesOnly
*/
public class NumberPropertiesOnlyTest {
private final NumberPropertiesOnly model = new NumberPropertiesOnly();
/**
* Model tests for NumberPropertiesOnly
*/
@Test
public void testNumberPropertiesOnly() {
// TODO: test NumberPropertiesOnly
}
/**
* Test the property 'number'
*/
@Test
public void numberTest() {
// TODO: test number
}
/**
* Test the property '_float'
*/
@Test
public void _floatTest() {
// TODO: test _float
}
/**
* Test the property '_double'
*/
@Test
public void _doubleTest() {
// TODO: test _double
}
}

View File

@ -13,6 +13,7 @@ docs/DataQueryAllOf.md
docs/DefaultValue.md
docs/FormApi.md
docs/HeaderApi.md
docs/NumberPropertiesOnly.md
docs/PathApi.md
docs/Pet.md
docs/Query.md
@ -58,6 +59,7 @@ src/main/java/org/openapitools/client/model/Category.java
src/main/java/org/openapitools/client/model/DataQuery.java
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
src/main/java/org/openapitools/client/model/DefaultValue.java
src/main/java/org/openapitools/client/model/NumberPropertiesOnly.java
src/main/java/org/openapitools/client/model/Pet.java
src/main/java/org/openapitools/client/model/Query.java
src/main/java/org/openapitools/client/model/StringEnumRef.java

View File

@ -134,6 +134,7 @@ Class | Method | HTTP request | Description
- [DataQuery](docs/DataQuery.md)
- [DataQueryAllOf](docs/DataQueryAllOf.md)
- [DefaultValue](docs/DefaultValue.md)
- [NumberPropertiesOnly](docs/NumberPropertiesOnly.md)
- [Pet](docs/Pet.md)
- [Query](docs/Query.md)
- [StringEnumRef](docs/StringEnumRef.md)

View File

@ -521,6 +521,19 @@ components:
allOf:
- $ref: '#/components/schemas/DataQuery_allOf'
- $ref: '#/components/schemas/Query'
NumberPropertiesOnly:
properties:
number:
type: number
float:
format: float
type: number
double:
format: double
maximum: 50.2
minimum: 0.8
type: number
type: object
test_form_integer_boolean_string_request:
properties:
integer_form:

View File

@ -0,0 +1,15 @@
# NumberPropertiesOnly
## Properties
| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**number** | **BigDecimal** | | [optional] |
|**_float** | **Float** | | [optional] |
|**_double** | **Double** | | [optional] |

View File

@ -98,6 +98,7 @@ public class JSON {
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DataQuery.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DataQueryAllOf.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DefaultValue.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.NumberPropertiesOnly.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Pet.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Tag.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.CustomTypeAdapterFactory());

View File

@ -0,0 +1,263 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* 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 java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.math.BigDecimal;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.openapitools.client.JSON;
/**
* NumberPropertiesOnly
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class NumberPropertiesOnly {
public static final String SERIALIZED_NAME_NUMBER = "number";
@SerializedName(SERIALIZED_NAME_NUMBER)
private BigDecimal number;
public static final String SERIALIZED_NAME_FLOAT = "float";
@SerializedName(SERIALIZED_NAME_FLOAT)
private Float _float;
public static final String SERIALIZED_NAME_DOUBLE = "double";
@SerializedName(SERIALIZED_NAME_DOUBLE)
private Double _double;
public NumberPropertiesOnly() {
}
public NumberPropertiesOnly number(BigDecimal number) {
this.number = number;
return this;
}
/**
* Get number
* @return number
**/
@javax.annotation.Nullable
public BigDecimal getNumber() {
return number;
}
public void setNumber(BigDecimal number) {
this.number = number;
}
public NumberPropertiesOnly _float(Float _float) {
this._float = _float;
return this;
}
/**
* Get _float
* @return _float
**/
@javax.annotation.Nullable
public Float getFloat() {
return _float;
}
public void setFloat(Float _float) {
this._float = _float;
}
public NumberPropertiesOnly _double(Double _double) {
this._double = _double;
return this;
}
/**
* Get _double
* minimum: 0.8
* maximum: 50.2
* @return _double
**/
@javax.annotation.Nullable
public Double getDouble() {
return _double;
}
public void setDouble(Double _double) {
this._double = _double;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
NumberPropertiesOnly numberPropertiesOnly = (NumberPropertiesOnly) o;
return Objects.equals(this.number, numberPropertiesOnly.number) &&
Objects.equals(this._float, numberPropertiesOnly._float) &&
Objects.equals(this._double, numberPropertiesOnly._double);
}
@Override
public int hashCode() {
return Objects.hash(number, _float, _double);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class NumberPropertiesOnly {\n");
sb.append(" number: ").append(toIndentedString(number)).append("\n");
sb.append(" _float: ").append(toIndentedString(_float)).append("\n");
sb.append(" _double: ").append(toIndentedString(_double)).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 ");
}
public static HashSet<String> openapiFields;
public static HashSet<String> openapiRequiredFields;
static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet<String>();
openapiFields.add("number");
openapiFields.add("float");
openapiFields.add("double");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet<String>();
}
/**
* Validates the JSON Object and throws an exception if issues found
*
* @param jsonObj JSON Object
* @throws IOException if the JSON Object is invalid with respect to NumberPropertiesOnly
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (!NumberPropertiesOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
throw new IllegalArgumentException(String.format("The required field(s) %s in NumberPropertiesOnly is not found in the empty JSON string", NumberPropertiesOnly.openapiRequiredFields.toString()));
}
}
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
// check to see if the JSON string contains additional fields
for (Entry<String, JsonElement> entry : entries) {
if (!NumberPropertiesOnly.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NumberPropertiesOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
}
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
if (!NumberPropertiesOnly.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'NumberPropertiesOnly' and its subtypes
}
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter<NumberPropertiesOnly> thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(NumberPropertiesOnly.class));
return (TypeAdapter<T>) new TypeAdapter<NumberPropertiesOnly>() {
@Override
public void write(JsonWriter out, NumberPropertiesOnly value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public NumberPropertiesOnly read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
return thisAdapter.fromJsonTree(jsonObj);
}
}.nullSafe();
}
}
/**
* Create an instance of NumberPropertiesOnly given an JSON string
*
* @param jsonString JSON string
* @return An instance of NumberPropertiesOnly
* @throws IOException if the JSON string is invalid with respect to NumberPropertiesOnly
*/
public static NumberPropertiesOnly fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, NumberPropertiesOnly.class);
}
/**
* Convert an instance of NumberPropertiesOnly to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}

View File

@ -0,0 +1,65 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
*
* 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 com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.math.BigDecimal;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Model tests for NumberPropertiesOnly
*/
public class NumberPropertiesOnlyTest {
private final NumberPropertiesOnly model = new NumberPropertiesOnly();
/**
* Model tests for NumberPropertiesOnly
*/
@Test
public void testNumberPropertiesOnly() {
// TODO: test NumberPropertiesOnly
}
/**
* Test the property 'number'
*/
@Test
public void numberTest() {
// TODO: test number
}
/**
* Test the property '_float'
*/
@Test
public void _floatTest() {
// TODO: test _float
}
/**
* Test the property '_double'
*/
@Test
public void _doubleTest() {
// TODO: test _double
}
}

View File

@ -11,6 +11,7 @@ docs/DataQueryAllOf.md
docs/DefaultValue.md
docs/FormApi.md
docs/HeaderApi.md
docs/NumberPropertiesOnly.md
docs/PathApi.md
docs/Pet.md
docs/Query.md
@ -36,6 +37,7 @@ openapi_client/models/category.py
openapi_client/models/data_query.py
openapi_client/models/data_query_all_of.py
openapi_client/models/default_value.py
openapi_client/models/number_properties_only.py
openapi_client/models/pet.py
openapi_client/models/query.py
openapi_client/models/string_enum_ref.py

View File

@ -107,6 +107,7 @@ Class | Method | HTTP request | Description
- [DataQuery](docs/DataQuery.md)
- [DataQueryAllOf](docs/DataQueryAllOf.md)
- [DefaultValue](docs/DefaultValue.md)
- [NumberPropertiesOnly](docs/NumberPropertiesOnly.md)
- [Pet](docs/Pet.md)
- [Query](docs/Query.md)
- [StringEnumRef](docs/StringEnumRef.md)

View File

@ -0,0 +1,30 @@
# NumberPropertiesOnly
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**number** | **float** | | [optional]
**float** | **float** | | [optional]
**double** | **float** | | [optional]
## Example
```python
from openapi_client.models.number_properties_only import NumberPropertiesOnly
# TODO update the JSON string below
json = "{}"
# create an instance of NumberPropertiesOnly from a JSON string
number_properties_only_instance = NumberPropertiesOnly.from_json(json)
# print the JSON string representation of the object
print NumberPropertiesOnly.to_json()
# convert the object into a dict
number_properties_only_dict = number_properties_only_instance.to_dict()
# create an instance of NumberPropertiesOnly from a dict
number_properties_only_form_dict = number_properties_only.from_dict(number_properties_only_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -39,6 +39,7 @@ from openapi_client.models.category import Category
from openapi_client.models.data_query import DataQuery
from openapi_client.models.data_query_all_of import DataQueryAllOf
from openapi_client.models.default_value import DefaultValue
from openapi_client.models.number_properties_only import NumberPropertiesOnly
from openapi_client.models.pet import Pet
from openapi_client.models.query import Query
from openapi_client.models.string_enum_ref import StringEnumRef

View File

@ -20,6 +20,7 @@ from openapi_client.models.category import Category
from openapi_client.models.data_query import DataQuery
from openapi_client.models.data_query_all_of import DataQueryAllOf
from openapi_client.models.default_value import DefaultValue
from openapi_client.models.number_properties_only import NumberPropertiesOnly
from openapi_client.models.pet import Pet
from openapi_client.models.query import Query
from openapi_client.models.string_enum_ref import StringEnumRef

View File

@ -0,0 +1,75 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
from __future__ import annotations
from inspect import getfullargspec
import pprint
import re # noqa: F401
import json
from typing import Optional, Union
from pydantic import BaseModel, StrictFloat, StrictInt, confloat, conint
class NumberPropertiesOnly(BaseModel):
"""
NumberPropertiesOnly
"""
number: Optional[Union[StrictFloat, StrictInt]] = None
float: Optional[Union[StrictFloat, StrictInt]] = None
double: Optional[Union[confloat(le=50.2, ge=0.8, strict=True), conint(le=50, ge=1, strict=True)]] = None
__properties = ["number", "float", "double"]
class Config:
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> NumberPropertiesOnly:
"""Create an instance of NumberPropertiesOnly from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
return _dict
@classmethod
def from_dict(cls, obj: dict) -> NumberPropertiesOnly:
"""Create an instance of NumberPropertiesOnly from a dict"""
if obj is None:
return None
if type(obj) is not dict:
return NumberPropertiesOnly.parse_obj(obj)
_obj = NumberPropertiesOnly.parse_obj({
"number": obj.get("number"),
"float": obj.get("float"),
"double": obj.get("double")
})
return _obj

View File

@ -59,6 +59,17 @@ class TestManual(unittest.TestCase):
api_response = api_instance.test_binary_gif()
self.assertEqual((base64.b64encode(api_response)).decode("utf-8"), "R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==")
def testNumberPropertiesOnly(self):
n = openapi_client.NumberPropertiesOnly.from_json('{"number": 123, "float": 456, "double": 34}')
self.assertEqual(n.number, 123)
self.assertEqual(n.float, 456)
self.assertEqual(n.double, 34)
n = openapi_client.NumberPropertiesOnly.from_json('{"number": 123.1, "float": 456.2, "double": 34.3}')
self.assertEqual(n.number, 123.1)
self.assertEqual(n.float, 456.2)
self.assertEqual(n.double, 34.3)
class EchoServerResponseParser():
def __init__(self, http_response):
if http_response is None:

View File

@ -0,0 +1,57 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
import unittest
import datetime
import openapi_client
from openapi_client.models.number_properties_only import NumberPropertiesOnly # noqa: E501
from openapi_client.rest import ApiException
class TestNumberPropertiesOnly(unittest.TestCase):
"""NumberPropertiesOnly unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test NumberPropertiesOnly
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `NumberPropertiesOnly`
"""
model = openapi_client.models.number_properties_only.NumberPropertiesOnly() # noqa: E501
if include_optional :
return NumberPropertiesOnly(
number = 1.337,
float = 1.337,
double = ''
)
else :
return NumberPropertiesOnly(
)
"""
def testNumberPropertiesOnly(self):
"""Test NumberPropertiesOnly"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -2060,15 +2060,15 @@ class FakeApi(object):
_request_auth=_params.get('_request_auth'))
@overload
async def test_endpoint_parameters(self, number : Annotated[confloat(ge=543.2, le=32.1), Field(..., description="None")], double : Annotated[confloat(ge=123.4, le=67.8), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(ge=987.6)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> None: # noqa: E501
async def test_endpoint_parameters(self, number : Annotated[confloat(le=543.2, ge=32.1), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(le=987.6)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> None: # noqa: E501
...
@overload
def test_endpoint_parameters(self, number : Annotated[confloat(ge=543.2, le=32.1), Field(..., description="None")], double : Annotated[confloat(ge=123.4, le=67.8), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(ge=987.6)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, async_req: Optional[bool]=True, **kwargs) -> None: # noqa: E501
def test_endpoint_parameters(self, number : Annotated[confloat(le=543.2, ge=32.1), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(le=987.6)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, async_req: Optional[bool]=True, **kwargs) -> None: # noqa: E501
...
@validate_arguments
def test_endpoint_parameters(self, number : Annotated[confloat(ge=543.2, le=32.1), Field(..., description="None")], double : Annotated[confloat(ge=123.4, le=67.8), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(ge=987.6)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[None, Awaitable[None]]: # noqa: E501
def test_endpoint_parameters(self, number : Annotated[confloat(le=543.2, ge=32.1), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(le=987.6)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[None, Awaitable[None]]: # noqa: E501
"""Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
@ -2127,7 +2127,7 @@ class FakeApi(object):
return self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, integer, int32, int64, float, string, binary, var_date, date_time, password, param_callback, **kwargs) # noqa: E501
@validate_arguments
def test_endpoint_parameters_with_http_info(self, number : Annotated[confloat(ge=543.2, le=32.1), Field(..., description="None")], double : Annotated[confloat(ge=123.4, le=67.8), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(ge=987.6)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs): # noqa: E501
def test_endpoint_parameters_with_http_info(self, number : Annotated[confloat(le=543.2, ge=32.1), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(le=987.6)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs): # noqa: E501
"""Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501

View File

@ -1929,7 +1929,7 @@ class FakeApi(object):
_request_auth=_params.get('_request_auth'))
@validate_arguments
def test_endpoint_parameters(self, number : Annotated[confloat(ge=543.2, le=32.1, strict=True), Field(..., description="None")], double : Annotated[confloat(ge=123.4, le=67.8, strict=True), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(ge=987.6, strict=True)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> None: # noqa: E501
def test_endpoint_parameters(self, number : Annotated[confloat(le=543.2, ge=32.1, strict=True), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8, strict=True), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(le=987.6, strict=True)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> None: # noqa: E501
"""Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
@ -1986,7 +1986,7 @@ class FakeApi(object):
return self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, integer, int32, int64, float, string, binary, var_date, date_time, password, param_callback, **kwargs) # noqa: E501
@validate_arguments
def test_endpoint_parameters_with_http_info(self, number : Annotated[confloat(ge=543.2, le=32.1, strict=True), Field(..., description="None")], double : Annotated[confloat(ge=123.4, le=67.8, strict=True), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(ge=987.6, strict=True)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs): # noqa: E501
def test_endpoint_parameters_with_http_info(self, number : Annotated[confloat(le=543.2, ge=32.1, strict=True), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8, strict=True), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[StrictStr, Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(le=987.6, strict=True)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[StrictStr], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs): # noqa: E501
"""Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501