mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-05 07:01:01 +00:00
[codegen][Go] Fix compilation error of generated go code when schema is free form object (#5391)
* Fix code generation for free-form objects in go-experimental * Execute scripts in bin directory * Add more use cases for open-ended types * Add more use cases for open-ended types * Add more use cases for open-ended types * add code comments * Better name for test properties * handle scenario when type is arbitrary * handle interface{} scenario * handle interface{} scenario * add helper function isAnyType * isAnyType function * implementation of isAnyType function * fix javadoc issue * handle interface{} scenario * use equals comparison instead of == * merge from master * Add code documentation * add code comments, remove unused min/max attribute, fix equals method * Handle 'anytype' use case * add code comments * override postProcessModelProperty to set vendor extension * Use vendorExtensions.x-golang-is-container * fix compilation error of generated code * fix compilation error of generated code * fix compilation error of generated code
This commit is contained in:
parent
256a431f03
commit
2c1ca02b61
@ -40,6 +40,8 @@ sidebar_label: go-experimental
|
|||||||
<li>int</li>
|
<li>int</li>
|
||||||
<li>int32</li>
|
<li>int32</li>
|
||||||
<li>int64</li>
|
<li>int64</li>
|
||||||
|
<li>interface{}</li>
|
||||||
|
<li>map[string]interface{}</li>
|
||||||
<li>rune</li>
|
<li>rune</li>
|
||||||
<li>string</li>
|
<li>string</li>
|
||||||
<li>uint</li>
|
<li>uint</li>
|
||||||
|
@ -33,6 +33,8 @@ sidebar_label: go-gin-server
|
|||||||
<li>int</li>
|
<li>int</li>
|
||||||
<li>int32</li>
|
<li>int32</li>
|
||||||
<li>int64</li>
|
<li>int64</li>
|
||||||
|
<li>interface{}</li>
|
||||||
|
<li>map[string]interface{}</li>
|
||||||
<li>rune</li>
|
<li>rune</li>
|
||||||
<li>string</li>
|
<li>string</li>
|
||||||
<li>uint</li>
|
<li>uint</li>
|
||||||
|
@ -36,6 +36,8 @@ sidebar_label: go-server
|
|||||||
<li>int</li>
|
<li>int</li>
|
||||||
<li>int32</li>
|
<li>int32</li>
|
||||||
<li>int64</li>
|
<li>int64</li>
|
||||||
|
<li>interface{}</li>
|
||||||
|
<li>map[string]interface{}</li>
|
||||||
<li>rune</li>
|
<li>rune</li>
|
||||||
<li>string</li>
|
<li>string</li>
|
||||||
<li>uint</li>
|
<li>uint</li>
|
||||||
|
@ -40,6 +40,8 @@ sidebar_label: go
|
|||||||
<li>int</li>
|
<li>int</li>
|
||||||
<li>int32</li>
|
<li>int32</li>
|
||||||
<li>int64</li>
|
<li>int64</li>
|
||||||
|
<li>interface{}</li>
|
||||||
|
<li>map[string]interface{}</li>
|
||||||
<li>rune</li>
|
<li>rune</li>
|
||||||
<li>string</li>
|
<li>string</li>
|
||||||
<li>uint</li>
|
<li>uint</li>
|
||||||
|
@ -20,12 +20,43 @@ package org.openapitools.codegen;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperties {
|
public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperties {
|
||||||
public String openApiType, baseName, complexType, getter, setter, description, dataType,
|
/**
|
||||||
datatypeWithEnum, dataFormat, name, min, max, defaultValue, defaultValueWithParam,
|
* The value of the 'type' attribute in the OpenAPI schema.
|
||||||
baseType, containerType, title;
|
* The per-language codegen logic may change to a language-specific type.
|
||||||
|
*/
|
||||||
|
public String openApiType;
|
||||||
|
public String baseName;
|
||||||
|
public String complexType;
|
||||||
|
public String getter;
|
||||||
|
public String setter;
|
||||||
|
/**
|
||||||
|
* The value of the 'description' attribute in the OpenAPI schema.
|
||||||
|
*/
|
||||||
|
public String description;
|
||||||
|
/**
|
||||||
|
* The language-specific data type for this property. For example, the OpenAPI type 'integer'
|
||||||
|
* may be represented as 'int', 'int32', 'Integer', etc, depending on the programming language.
|
||||||
|
*/
|
||||||
|
public String dataType;
|
||||||
|
public String datatypeWithEnum;
|
||||||
|
public String dataFormat;
|
||||||
|
/**
|
||||||
|
* The name of this property in the OpenAPI schema.
|
||||||
|
*/
|
||||||
|
public String name;
|
||||||
|
public String min; // TODO: is this really used?
|
||||||
|
public String max; // TODO: is this really used?
|
||||||
|
public String defaultValue;
|
||||||
|
public String defaultValueWithParam;
|
||||||
|
public String baseType;
|
||||||
|
public String containerType;
|
||||||
|
/**
|
||||||
|
* The value of the 'title' attribute in the OpenAPI schema.
|
||||||
|
*/
|
||||||
|
public String title;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The 'description' string without escape charcters needed by some programming languages/targets
|
* The 'description' string without escape characters needed by some programming languages/targets
|
||||||
*/
|
*/
|
||||||
public String unescapedDescription;
|
public String unescapedDescription;
|
||||||
|
|
||||||
@ -47,10 +78,30 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
|||||||
public String example;
|
public String example;
|
||||||
|
|
||||||
public String jsonSchema;
|
public String jsonSchema;
|
||||||
|
/**
|
||||||
|
* The value of the 'minimum' attribute in the OpenAPI schema.
|
||||||
|
* The value of "minimum" MUST be a number, representing an inclusive lower limit for a numeric instance.
|
||||||
|
*/
|
||||||
public String minimum;
|
public String minimum;
|
||||||
|
/**
|
||||||
|
* The value of the 'maximum' attribute in the OpenAPI schema.
|
||||||
|
* The value of "maximum" MUST be a number, representing an inclusive upper limit for a numeric instance.
|
||||||
|
*/
|
||||||
public String maximum;
|
public String maximum;
|
||||||
|
/**
|
||||||
|
* The value of the 'multipleOf' attribute in the OpenAPI schema.
|
||||||
|
* The value of "multipleOf" MUST be a number, strictly greater than 0.
|
||||||
|
*/
|
||||||
public Number multipleOf;
|
public Number multipleOf;
|
||||||
|
/**
|
||||||
|
* The value of the 'exclusiveMinimum' attribute in the OpenAPI schema.
|
||||||
|
* The value of "exclusiveMinimum" MUST be number, representing an exclusive lower limit for a numeric instance.
|
||||||
|
*/
|
||||||
public boolean exclusiveMinimum;
|
public boolean exclusiveMinimum;
|
||||||
|
/**
|
||||||
|
* The value of the 'exclusiveMaximum' attribute in the OpenAPI schema.
|
||||||
|
* The value of "exclusiveMaximum" MUST be number, representing an exclusive upper limit for a numeric instance.
|
||||||
|
*/
|
||||||
public boolean exclusiveMaximum;
|
public boolean exclusiveMaximum;
|
||||||
public boolean hasMore;
|
public boolean hasMore;
|
||||||
public boolean required;
|
public boolean required;
|
||||||
@ -59,6 +110,12 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
|||||||
public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly
|
public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly
|
||||||
public boolean isPrimitiveType;
|
public boolean isPrimitiveType;
|
||||||
public boolean isModel;
|
public boolean isModel;
|
||||||
|
/**
|
||||||
|
* True if this property is an array of items or a map container.
|
||||||
|
* See:
|
||||||
|
* - ModelUtils.isArraySchema()
|
||||||
|
* - ModelUtils.isMapSchema()
|
||||||
|
*/
|
||||||
public boolean isContainer;
|
public boolean isContainer;
|
||||||
public boolean isString;
|
public boolean isString;
|
||||||
public boolean isNumeric;
|
public boolean isNumeric;
|
||||||
@ -76,7 +133,15 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
|||||||
public boolean isUuid;
|
public boolean isUuid;
|
||||||
public boolean isUri;
|
public boolean isUri;
|
||||||
public boolean isEmail;
|
public boolean isEmail;
|
||||||
|
/**
|
||||||
|
* The type is a free-form object, i.e. it is a map of string to values with no declared properties
|
||||||
|
*/
|
||||||
public boolean isFreeFormObject;
|
public boolean isFreeFormObject;
|
||||||
|
/**
|
||||||
|
* The 'type' in the OAS schema is unspecified (i.e. not set). The value can be number, integer, string, object or array.
|
||||||
|
* If the nullable attribute is set to true, the 'null' value is valid.
|
||||||
|
*/
|
||||||
|
public boolean isAnyType;
|
||||||
public boolean isListContainer;
|
public boolean isListContainer;
|
||||||
public boolean isMapContainer;
|
public boolean isMapContainer;
|
||||||
public boolean isEnum;
|
public boolean isEnum;
|
||||||
@ -621,7 +686,7 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
|||||||
exclusiveMaximum == that.exclusiveMaximum &&
|
exclusiveMaximum == that.exclusiveMaximum &&
|
||||||
hasMore == that.hasMore &&
|
hasMore == that.hasMore &&
|
||||||
required == that.required &&
|
required == that.required &&
|
||||||
deprecated == this.deprecated &&
|
deprecated == that.deprecated &&
|
||||||
secondaryParam == that.secondaryParam &&
|
secondaryParam == that.secondaryParam &&
|
||||||
hasMoreNonReadOnly == that.hasMoreNonReadOnly &&
|
hasMoreNonReadOnly == that.hasMoreNonReadOnly &&
|
||||||
isPrimitiveType == that.isPrimitiveType &&
|
isPrimitiveType == that.isPrimitiveType &&
|
||||||
|
@ -1945,6 +1945,8 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
return "string";
|
return "string";
|
||||||
} else if (ModelUtils.isFreeFormObject(schema)) {
|
} else if (ModelUtils.isFreeFormObject(schema)) {
|
||||||
|
// Note: the value of a free-form object cannot be an arbitrary type. Per OAS specification,
|
||||||
|
// it must be a map of string to values.
|
||||||
return "object";
|
return "object";
|
||||||
} else if (schema.getProperties() != null && !schema.getProperties().isEmpty()) { // having property implies it's a model
|
} else if (schema.getProperties() != null && !schema.getProperties().isEmpty()) { // having property implies it's a model
|
||||||
return "object";
|
return "object";
|
||||||
@ -1952,7 +1954,10 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
LOGGER.warn("Unknown type found in the schema: " + schema.getType());
|
LOGGER.warn("Unknown type found in the schema: " + schema.getType());
|
||||||
return schema.getType();
|
return schema.getType();
|
||||||
}
|
}
|
||||||
|
// The 'type' attribute has not been set in the OAS schema, which means the value
|
||||||
|
// can be an arbitrary type, e.g. integer, string, object, array, number...
|
||||||
|
// TODO: we should return a different value to distinguish between free-form object
|
||||||
|
// and arbitrary type.
|
||||||
return "object";
|
return "object";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2707,6 +2712,9 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
setNonArrayMapProperty(property, type);
|
setNonArrayMapProperty(property, type);
|
||||||
Schema refOrCurrent = ModelUtils.getReferencedSchema(this.openAPI, p);
|
Schema refOrCurrent = ModelUtils.getReferencedSchema(this.openAPI, p);
|
||||||
property.isModel = (ModelUtils.isComposedSchema(refOrCurrent) || ModelUtils.isObjectSchema(refOrCurrent)) && ModelUtils.isModel(refOrCurrent);
|
property.isModel = (ModelUtils.isComposedSchema(refOrCurrent) || ModelUtils.isObjectSchema(refOrCurrent)) && ModelUtils.isModel(refOrCurrent);
|
||||||
|
if (ModelUtils.isAnyTypeSchema(p)) {
|
||||||
|
property.isAnyType = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.debug("debugging from property return: " + property);
|
LOGGER.debug("debugging from property return: " + property);
|
||||||
|
@ -91,7 +91,10 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
"complex64",
|
"complex64",
|
||||||
"complex128",
|
"complex128",
|
||||||
"rune",
|
"rune",
|
||||||
"byte")
|
"byte",
|
||||||
|
"map[string]interface{}",
|
||||||
|
"interface{}"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
instantiationTypes.clear();
|
instantiationTypes.clear();
|
||||||
@ -116,7 +119,17 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
typeMapping.put("file", "*os.File");
|
typeMapping.put("file", "*os.File");
|
||||||
typeMapping.put("binary", "*os.File");
|
typeMapping.put("binary", "*os.File");
|
||||||
typeMapping.put("ByteArray", "string");
|
typeMapping.put("ByteArray", "string");
|
||||||
|
// A 'type: object' OAS schema without any declared property is
|
||||||
|
// (per JSON schema specification) "an unordered set of properties
|
||||||
|
// mapping a string to an instance".
|
||||||
|
// Hence map[string]interface{} is the proper implementation in golang.
|
||||||
|
// Note: OpenAPITools uses the same token 'object' for free-form objects
|
||||||
|
// and arbitrary types. A free form object is implemented in golang as
|
||||||
|
// map[string]interface{}, whereas an arbitrary type is implemented
|
||||||
|
// in golang as interface{}.
|
||||||
|
// See issue #5387 for more details.
|
||||||
typeMapping.put("object", "map[string]interface{}");
|
typeMapping.put("object", "map[string]interface{}");
|
||||||
|
typeMapping.put("interface{}", "interface{}");
|
||||||
|
|
||||||
numberTypes = new HashSet<String>(
|
numberTypes = new HashSet<String>(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
@ -303,6 +316,12 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the golang implementation type for the specified property.
|
||||||
|
*
|
||||||
|
* @param p the OAS property.
|
||||||
|
* @return the golang implementation type.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getTypeDeclaration(Schema p) {
|
public String getTypeDeclaration(Schema p) {
|
||||||
if (ModelUtils.isArraySchema(p)) {
|
if (ModelUtils.isArraySchema(p)) {
|
||||||
@ -342,6 +361,12 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
return toModelName(openAPIType);
|
return toModelName(openAPIType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the OpenAPI type for the property.
|
||||||
|
*
|
||||||
|
* @param p the OAS property.
|
||||||
|
* @return the OpenAPI type.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getSchemaType(Schema p) {
|
public String getSchemaType(Schema p) {
|
||||||
String openAPIType = super.getSchemaType(p);
|
String openAPIType = super.getSchemaType(p);
|
||||||
@ -350,6 +375,9 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
|
|
||||||
if (ref != null && !ref.isEmpty()) {
|
if (ref != null && !ref.isEmpty()) {
|
||||||
type = openAPIType;
|
type = openAPIType;
|
||||||
|
} else if ("object".equals(openAPIType) && ModelUtils.isAnyTypeSchema(p)) {
|
||||||
|
// Arbitrary type. Note this is not the same thing as free-form object.
|
||||||
|
type = "interface{}";
|
||||||
} else if (typeMapping.containsKey(openAPIType)) {
|
} else if (typeMapping.containsKey(openAPIType)) {
|
||||||
type = typeMapping.get(openAPIType);
|
type = typeMapping.get(openAPIType);
|
||||||
if (languageSpecificPrimitives.contains(type))
|
if (languageSpecificPrimitives.contains(type))
|
||||||
@ -556,6 +584,17 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||||
|
// The 'go-experimental/model.mustache' template conditionally generates accessor methods.
|
||||||
|
// For primitive types and custom types (e.g. interface{}, map[string]interface{}...),
|
||||||
|
// the generated code has a wrapper type and a Get() function to access the underlying type.
|
||||||
|
// For containers (e.g. Array, Map), the generated code returns the type directly.
|
||||||
|
if (property.isContainer || property.isFreeFormObject || property.isAnyType) {
|
||||||
|
property.vendorExtensions.put("x-golang-is-container", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
// remove model imports to avoid error
|
// remove model imports to avoid error
|
||||||
|
@ -167,7 +167,8 @@ public class GoClientExperimentalCodegen extends GoClientCodegen {
|
|||||||
|
|
||||||
for (CodegenProperty param : model.vars) {
|
for (CodegenProperty param : model.vars) {
|
||||||
param.vendorExtensions.put("x-go-base-type", param.dataType);
|
param.vendorExtensions.put("x-go-base-type", param.dataType);
|
||||||
if (!param.isNullable || param.isMapContainer || param.isListContainer) {
|
if (!param.isNullable || param.isMapContainer || param.isListContainer ||
|
||||||
|
param.isFreeFormObject || param.isAnyType) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (param.isDateTime) {
|
if (param.isDateTime) {
|
||||||
|
@ -636,7 +636,7 @@ public class ModelUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if the schema is a model with at least one properties
|
* Check to see if the schema is a model with at least one property.
|
||||||
*
|
*
|
||||||
* @param schema potentially containing a '$ref'
|
* @param schema potentially containing a '$ref'
|
||||||
* @return true if it's a model with at least one properties
|
* @return true if it's a model with at least one properties
|
||||||
@ -657,6 +657,42 @@ public class ModelUtils {
|
|||||||
return schema instanceof ComposedSchema;
|
return schema instanceof ComposedSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the schema value can be any type, i.e. it can be
|
||||||
|
* the null value, integer, number, string, object or array.
|
||||||
|
* One use case is when the "type" attribute in the OAS schema is unspecified.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* arbitraryTypeValue:
|
||||||
|
* description: This is an arbitrary type schema.
|
||||||
|
* It is not a free-form object.
|
||||||
|
* The value can be any type except the 'null' value.
|
||||||
|
* arbitraryTypeNullableValue:
|
||||||
|
* description: This is an arbitrary type schema.
|
||||||
|
* It is not a free-form object.
|
||||||
|
* The value can be any type, including the 'null' value.
|
||||||
|
* nullable: true
|
||||||
|
*
|
||||||
|
* @param schema the OAS schema.
|
||||||
|
* @return true if the schema value can be an arbitrary type.
|
||||||
|
*/
|
||||||
|
public static boolean isAnyTypeSchema(Schema schema) {
|
||||||
|
if (schema == null) {
|
||||||
|
once(LOGGER).error("Schema cannot be null in isAnyTypeSchema check");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (schema.getClass().equals(Schema.class) && schema.get$ref() == null && schema.getType() == null &&
|
||||||
|
(schema.getProperties() == null || schema.getProperties().isEmpty()) &&
|
||||||
|
schema.getAdditionalProperties() == null && schema.getNot() == null &&
|
||||||
|
schema.getEnum() == null) {
|
||||||
|
return true;
|
||||||
|
// If and when type arrays are supported in a future OAS specification,
|
||||||
|
// we could return true if the type array includes all possible JSON schema types.
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if the schema is a free form object.
|
* Check to see if the schema is a free form object.
|
||||||
*
|
*
|
||||||
@ -665,6 +701,25 @@ public class ModelUtils {
|
|||||||
* 2) Is not a composed schema (no anyOf, oneOf, allOf), and
|
* 2) Is not a composed schema (no anyOf, oneOf, allOf), and
|
||||||
* 3) additionalproperties is not defined, or additionalproperties: true, or additionalproperties: {}.
|
* 3) additionalproperties is not defined, or additionalproperties: true, or additionalproperties: {}.
|
||||||
*
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* components:
|
||||||
|
* schemas:
|
||||||
|
* arbitraryObject:
|
||||||
|
* type: object
|
||||||
|
* description: This is a free-form object.
|
||||||
|
* The value must be a map of strings to values. The value cannot be 'null'.
|
||||||
|
* It cannot be array, string, integer, number.
|
||||||
|
* arbitraryNullableObject:
|
||||||
|
* type: object
|
||||||
|
* description: This is a free-form object.
|
||||||
|
* The value must be a map of strings to values. The value can be 'null',
|
||||||
|
* It cannot be array, string, integer, number.
|
||||||
|
* nullable: true
|
||||||
|
* arbitraryTypeValue:
|
||||||
|
* description: This is NOT a free-form object.
|
||||||
|
* The value can be any type except the 'null' value.
|
||||||
|
*
|
||||||
* @param schema potentially containing a '$ref'
|
* @param schema potentially containing a '$ref'
|
||||||
* @return true if it's a free-form object
|
* @return true if it's a free-form object
|
||||||
*/
|
*/
|
||||||
|
@ -69,7 +69,7 @@ func New{{classname}}({{#vars}}{{#required}}{{nameInCamelCase}} {{dataType}}, {{
|
|||||||
{{/required}}
|
{{/required}}
|
||||||
{{^required}}
|
{{^required}}
|
||||||
{{#defaultValue}}
|
{{#defaultValue}}
|
||||||
{{^isContainer}}
|
{{^vendorExtensions.x-golang-is-container}}
|
||||||
{{#isNullable}}
|
{{#isNullable}}
|
||||||
var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}}
|
var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}}
|
||||||
this.{{name}} = *New{{{dataType}}}(&{{nameInCamelCase}})
|
this.{{name}} = *New{{{dataType}}}(&{{nameInCamelCase}})
|
||||||
@ -78,7 +78,7 @@ func New{{classname}}({{#vars}}{{#required}}{{nameInCamelCase}} {{dataType}}, {{
|
|||||||
var {{nameInCamelCase}} {{{dataType}}} = {{{.}}}
|
var {{nameInCamelCase}} {{{dataType}}} = {{{.}}}
|
||||||
this.{{name}} = &{{nameInCamelCase}}
|
this.{{name}} = &{{nameInCamelCase}}
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{/defaultValue}}
|
{{/defaultValue}}
|
||||||
{{/required}}
|
{{/required}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
@ -92,7 +92,7 @@ func New{{classname}}WithDefaults() *{{classname}} {
|
|||||||
this := {{classname}}{}
|
this := {{classname}}{}
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#defaultValue}}
|
{{#defaultValue}}
|
||||||
{{^isContainer}}
|
{{^vendorExtensions.x-golang-is-container}}
|
||||||
{{#isNullable}}
|
{{#isNullable}}
|
||||||
{{!we use datatypeWithEnum here, since it will represent the non-nullable name of the datatype, e.g. int64 for NullableInt64}}
|
{{!we use datatypeWithEnum here, since it will represent the non-nullable name of the datatype, e.g. int64 for NullableInt64}}
|
||||||
var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}}
|
var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}}
|
||||||
@ -102,7 +102,7 @@ func New{{classname}}WithDefaults() *{{classname}} {
|
|||||||
var {{nameInCamelCase}} {{{dataType}}} = {{{.}}}
|
var {{nameInCamelCase}} {{{dataType}}} = {{{.}}}
|
||||||
this.{{name}} = {{^required}}&{{/required}}{{nameInCamelCase}}
|
this.{{name}} = {{^required}}&{{/required}}{{nameInCamelCase}}
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{/defaultValue}}
|
{{/defaultValue}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
return &this
|
return &this
|
||||||
@ -115,18 +115,18 @@ func New{{classname}}WithDefaults() *{{classname}} {
|
|||||||
// If the value is explicit nil, the zero value for {{vendorExtensions.x-go-base-type}} will be returned
|
// If the value is explicit nil, the zero value for {{vendorExtensions.x-go-base-type}} will be returned
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
|
func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
|
||||||
if o == nil {{#isNullable}}{{^isContainer}}|| o.{{name}}.Get() == nil{{/isContainer}}{{/isNullable}} {
|
if o == nil {{#isNullable}}{{^vendorExtensions.x-golang-is-container}}|| o.{{name}}.Get() == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
|
||||||
var ret {{vendorExtensions.x-go-base-type}}
|
var ret {{vendorExtensions.x-go-base-type}}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#isNullable}}
|
{{#isNullable}}
|
||||||
{{#isContainer}}
|
{{#vendorExtensions.x-golang-is-container}}
|
||||||
return o.{{name}}
|
return o.{{name}}
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{^isContainer}}
|
{{^vendorExtensions.x-golang-is-container}}
|
||||||
return *o.{{name}}.Get()
|
return *o.{{name}}.Get()
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
{{^isNullable}}
|
{{^isNullable}}
|
||||||
return o.{{name}}
|
return o.{{name}}
|
||||||
@ -139,16 +139,16 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
|
|||||||
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-go-base-type}}, bool) {
|
func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-go-base-type}}, bool) {
|
||||||
if o == nil {{#isNullable}}{{#isContainer}}|| o.{{name}} == nil{{/isContainer}}{{/isNullable}} {
|
if o == nil {{#isNullable}}{{#vendorExtensions.x-golang-is-container}}|| o.{{name}} == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
{{#isNullable}}
|
{{#isNullable}}
|
||||||
{{#isContainer}}
|
{{#vendorExtensions.x-golang-is-container}}
|
||||||
return &o.{{name}}, true
|
return &o.{{name}}, true
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{^isContainer}}
|
{{^vendorExtensions.x-golang-is-container}}
|
||||||
return o.{{name}}.Get(), o.{{name}}.IsSet()
|
return o.{{name}}.Get(), o.{{name}}.IsSet()
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
{{^isNullable}}
|
{{^isNullable}}
|
||||||
return &o.{{name}}, true
|
return &o.{{name}}, true
|
||||||
@ -158,12 +158,12 @@ func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-go-base-type}}, b
|
|||||||
// Set{{name}} sets field value
|
// Set{{name}} sets field value
|
||||||
func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
|
func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
|
||||||
{{#isNullable}}
|
{{#isNullable}}
|
||||||
{{#isContainer}}
|
{{#vendorExtensions.x-golang-is-container}}
|
||||||
o.{{name}} = v
|
o.{{name}} = v
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{^isContainer}}
|
{{^vendorExtensions.x-golang-is-container}}
|
||||||
o.{{name}}.Set(&v)
|
o.{{name}}.Set(&v)
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
{{^isNullable}}
|
{{^isNullable}}
|
||||||
o.{{name}} = v
|
o.{{name}} = v
|
||||||
@ -174,17 +174,17 @@ func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
|
|||||||
{{^required}}
|
{{^required}}
|
||||||
// Get{{name}} returns the {{name}} field value if set, zero value otherwise{{#isNullable}} (both if not set or set to explicit null){{/isNullable}}.
|
// Get{{name}} returns the {{name}} field value if set, zero value otherwise{{#isNullable}} (both if not set or set to explicit null){{/isNullable}}.
|
||||||
func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
|
func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
|
||||||
if o == nil {{^isNullable}}|| o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{^isContainer}}|| o.{{name}}.Get() == nil{{/isContainer}}{{/isNullable}} {
|
if o == nil {{^isNullable}}|| o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{^vendorExtensions.x-golang-is-container}}|| o.{{name}}.Get() == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
|
||||||
var ret {{vendorExtensions.x-go-base-type}}
|
var ret {{vendorExtensions.x-go-base-type}}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
{{#isNullable}}
|
{{#isNullable}}
|
||||||
{{#isContainer}}
|
{{#vendorExtensions.x-golang-is-container}}
|
||||||
return o.{{name}}
|
return o.{{name}}
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{^isContainer}}
|
{{^vendorExtensions.x-golang-is-container}}
|
||||||
return *o.{{name}}.Get()
|
return *o.{{name}}.Get()
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
{{^isNullable}}
|
{{^isNullable}}
|
||||||
return *o.{{name}}
|
return *o.{{name}}
|
||||||
@ -197,16 +197,16 @@ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
|
|||||||
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-go-base-type}}, bool) {
|
func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-go-base-type}}, bool) {
|
||||||
if o == nil {{^isNullable}}|| o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{#isContainer}}|| o.{{name}} == nil{{/isContainer}}{{/isNullable}} {
|
if o == nil {{^isNullable}}|| o.{{name}} == nil{{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}}|| o.{{name}} == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
{{#isNullable}}
|
{{#isNullable}}
|
||||||
{{#isContainer}}
|
{{#vendorExtensions.x-golang-is-container}}
|
||||||
return &o.{{name}}, true
|
return &o.{{name}}, true
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{^isContainer}}
|
{{^vendorExtensions.x-golang-is-container}}
|
||||||
return o.{{name}}.Get(), o.{{name}}.IsSet()
|
return o.{{name}}.Get(), o.{{name}}.IsSet()
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
{{^isNullable}}
|
{{^isNullable}}
|
||||||
return o.{{name}}, true
|
return o.{{name}}, true
|
||||||
@ -215,7 +215,7 @@ func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-go-base-type}}, b
|
|||||||
|
|
||||||
// Has{{name}} returns a boolean if a field has been set.
|
// Has{{name}} returns a boolean if a field has been set.
|
||||||
func (o *{{classname}}) Has{{name}}() bool {
|
func (o *{{classname}}) Has{{name}}() bool {
|
||||||
if o != nil && {{^isNullable}}o.{{name}} != nil{{/isNullable}}{{#isNullable}}{{#isContainer}}o.{{name}} != nil{{/isContainer}}{{^isContainer}}o.{{name}}.IsSet(){{/isContainer}}{{/isNullable}} {
|
if o != nil && {{^isNullable}}o.{{name}} != nil{{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}}o.{{name}} != nil{{/vendorExtensions.x-golang-is-container}}{{^vendorExtensions.x-golang-is-container}}o.{{name}}.IsSet(){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,19 +225,19 @@ func (o *{{classname}}) Has{{name}}() bool {
|
|||||||
// Set{{name}} gets a reference to the given {{dataType}} and assigns it to the {{name}} field.
|
// Set{{name}} gets a reference to the given {{dataType}} and assigns it to the {{name}} field.
|
||||||
func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
|
func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
|
||||||
{{#isNullable}}
|
{{#isNullable}}
|
||||||
{{#isContainer}}
|
{{#vendorExtensions.x-golang-is-container}}
|
||||||
o.{{name}} = v
|
o.{{name}} = v
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{^isContainer}}
|
{{^vendorExtensions.x-golang-is-container}}
|
||||||
o.{{name}}.Set(&v)
|
o.{{name}}.Set(&v)
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
{{^isNullable}}
|
{{^isNullable}}
|
||||||
o.{{name}} = &v
|
o.{{name}} = &v
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
}
|
}
|
||||||
{{#isNullable}}
|
{{#isNullable}}
|
||||||
{{^isContainer}}
|
{{^vendorExtensions.x-golang-is-container}}
|
||||||
// Set{{name}}Nil sets the value for {{name}} to be an explicit nil
|
// Set{{name}}Nil sets the value for {{name}} to be an explicit nil
|
||||||
func (o *{{classname}}) Set{{name}}Nil() {
|
func (o *{{classname}}) Set{{name}}Nil() {
|
||||||
o.{{name}}.Set(nil)
|
o.{{name}}.Set(nil)
|
||||||
@ -247,7 +247,7 @@ func (o *{{classname}}) Set{{name}}Nil() {
|
|||||||
func (o *{{classname}}) Unset{{name}}() {
|
func (o *{{classname}}) Unset{{name}}() {
|
||||||
o.{{name}}.Unset()
|
o.{{name}}.Unset()
|
||||||
}
|
}
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
|
|
||||||
{{/required}}
|
{{/required}}
|
||||||
@ -269,17 +269,17 @@ func (o {{classname}}) MarshalJSON() ([]byte, error) {
|
|||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{! if argument is nullable, only serialize it if it is set}}
|
{{! if argument is nullable, only serialize it if it is set}}
|
||||||
{{#isNullable}}
|
{{#isNullable}}
|
||||||
{{#isContainer}}
|
{{#vendorExtensions.x-golang-is-container}}
|
||||||
{{! support for container fields is not ideal at this point because of lack of Nullable* types}}
|
{{! support for container fields is not ideal at this point because of lack of Nullable* types}}
|
||||||
if o.{{name}} != nil {
|
if o.{{name}} != nil {
|
||||||
toSerialize["{{baseName}}"] = o.{{name}}
|
toSerialize["{{baseName}}"] = o.{{name}}
|
||||||
}
|
}
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{^isContainer}}
|
{{^vendorExtensions.x-golang-is-container}}
|
||||||
if {{#required}}true{{/required}}{{^required}}o.{{name}}.IsSet(){{/required}} {
|
if {{#required}}true{{/required}}{{^required}}o.{{name}}.IsSet(){{/required}} {
|
||||||
toSerialize["{{baseName}}"] = o.{{name}}.Get()
|
toSerialize["{{baseName}}"] = o.{{name}}.Get()
|
||||||
}
|
}
|
||||||
{{/isContainer}}
|
{{/vendorExtensions.x-golang-is-container}}
|
||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
{{! if argument is not nullable, don't set it if it is nil}}
|
{{! if argument is not nullable, don't set it if it is nil}}
|
||||||
{{^isNullable}}
|
{{^isNullable}}
|
||||||
|
@ -1250,6 +1250,23 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
description: User Status
|
description: User Status
|
||||||
|
arbitraryObject:
|
||||||
|
type: object
|
||||||
|
description: test code generation for objects
|
||||||
|
Value must be a map of strings to values. It cannot be the 'null' value.
|
||||||
|
arbitraryNullableObject:
|
||||||
|
type: object
|
||||||
|
description: test code generation for nullable objects.
|
||||||
|
Value must be a map of strings to values or the 'null' value.
|
||||||
|
nullable: true
|
||||||
|
arbitraryTypeValue:
|
||||||
|
description: test code generation for any type
|
||||||
|
Value can be any type - string, number, boolean, array or object.
|
||||||
|
arbitraryNullableTypeValue:
|
||||||
|
description: test code generation for any type
|
||||||
|
Value can be any type - string, number, boolean, array, object or
|
||||||
|
the 'null' value.
|
||||||
|
nullable: true
|
||||||
xml:
|
xml:
|
||||||
name: User
|
name: User
|
||||||
Tag:
|
Tag:
|
||||||
|
@ -1299,9 +1299,13 @@ components:
|
|||||||
lastName: lastName
|
lastName: lastName
|
||||||
password: password
|
password: password
|
||||||
userStatus: 6
|
userStatus: 6
|
||||||
|
arbitraryTypeValue: ""
|
||||||
|
arbitraryNullableTypeValue: ""
|
||||||
phone: phone
|
phone: phone
|
||||||
id: 0
|
id: 0
|
||||||
|
arbitraryObject: '{}'
|
||||||
email: email
|
email: email
|
||||||
|
arbitraryNullableObject: '{}'
|
||||||
username: username
|
username: username
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
@ -1324,6 +1328,22 @@ components:
|
|||||||
description: User Status
|
description: User Status
|
||||||
format: int32
|
format: int32
|
||||||
type: integer
|
type: integer
|
||||||
|
arbitraryObject:
|
||||||
|
description: test code generation for objects Value must be a map of strings
|
||||||
|
to values. It cannot be the 'null' value.
|
||||||
|
type: object
|
||||||
|
arbitraryNullableObject:
|
||||||
|
description: test code generation for nullable objects. Value must be a
|
||||||
|
map of strings to values or the 'null' value.
|
||||||
|
nullable: true
|
||||||
|
type: object
|
||||||
|
arbitraryTypeValue:
|
||||||
|
description: test code generation for any type Value can be any type - string,
|
||||||
|
number, boolean, array or object.
|
||||||
|
arbitraryNullableTypeValue:
|
||||||
|
description: test code generation for any type Value can be any type - string,
|
||||||
|
number, boolean, array, object or the 'null' value.
|
||||||
|
nullable: true
|
||||||
type: object
|
type: object
|
||||||
xml:
|
xml:
|
||||||
name: User
|
name: User
|
||||||
|
@ -10,12 +10,12 @@ Name | Type | Description | Notes
|
|||||||
**StringProp** | Pointer to **NullableString** | | [optional]
|
**StringProp** | Pointer to **NullableString** | | [optional]
|
||||||
**DateProp** | Pointer to **NullableString** | | [optional]
|
**DateProp** | Pointer to **NullableString** | | [optional]
|
||||||
**DatetimeProp** | Pointer to [**NullableTime**](time.Time.md) | | [optional]
|
**DatetimeProp** | Pointer to [**NullableTime**](time.Time.md) | | [optional]
|
||||||
**ArrayNullableProp** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ArrayNullableProp** | Pointer to **[]map[string]interface{}** | | [optional]
|
||||||
**ArrayAndItemsNullableProp** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ArrayAndItemsNullableProp** | Pointer to **[]map[string]interface{}** | | [optional]
|
||||||
**ArrayItemsNullable** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ArrayItemsNullable** | Pointer to **[]map[string]interface{}** | | [optional]
|
||||||
**ObjectNullableProp** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ObjectNullableProp** | Pointer to **map[string]map[string]interface{}** | | [optional]
|
||||||
**ObjectAndItemsNullableProp** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ObjectAndItemsNullableProp** | Pointer to **map[string]map[string]interface{}** | | [optional]
|
||||||
**ObjectItemsNullable** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ObjectItemsNullable** | Pointer to **map[string]map[string]interface{}** | | [optional]
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
|
@ -12,6 +12,10 @@ Name | Type | Description | Notes
|
|||||||
**Password** | Pointer to **string** | | [optional]
|
**Password** | Pointer to **string** | | [optional]
|
||||||
**Phone** | Pointer to **string** | | [optional]
|
**Phone** | Pointer to **string** | | [optional]
|
||||||
**UserStatus** | Pointer to **int32** | User Status | [optional]
|
**UserStatus** | Pointer to **int32** | User Status | [optional]
|
||||||
|
**ArbitraryObject** | Pointer to [**map[string]interface{}**](.md) | test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. | [optional]
|
||||||
|
**ArbitraryNullableObject** | Pointer to [**map[string]interface{}**](.md) | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [optional]
|
||||||
|
**ArbitraryTypeValue** | Pointer to **interface{}** | test code generation for any type Value can be any type - string, number, boolean, array or object. | [optional]
|
||||||
|
**ArbitraryNullableTypeValue** | Pointer to **interface{}** | test code generation for any type Value can be any type - string, number, boolean, array, object or the 'null' value. | [optional]
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
@ -232,6 +236,126 @@ SetUserStatus sets UserStatus field to given value.
|
|||||||
|
|
||||||
HasUserStatus returns a boolean if a field has been set.
|
HasUserStatus returns a boolean if a field has been set.
|
||||||
|
|
||||||
|
### GetArbitraryObject
|
||||||
|
|
||||||
|
`func (o *User) GetArbitraryObject() map[string]interface{}`
|
||||||
|
|
||||||
|
GetArbitraryObject returns the ArbitraryObject field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
|
### GetArbitraryObjectOk
|
||||||
|
|
||||||
|
`func (o *User) GetArbitraryObjectOk() (*map[string]interface{}, bool)`
|
||||||
|
|
||||||
|
GetArbitraryObjectOk returns a tuple with the ArbitraryObject field if it's non-nil, zero value otherwise
|
||||||
|
and a boolean to check if the value has been set.
|
||||||
|
|
||||||
|
### SetArbitraryObject
|
||||||
|
|
||||||
|
`func (o *User) SetArbitraryObject(v map[string]interface{})`
|
||||||
|
|
||||||
|
SetArbitraryObject sets ArbitraryObject field to given value.
|
||||||
|
|
||||||
|
### HasArbitraryObject
|
||||||
|
|
||||||
|
`func (o *User) HasArbitraryObject() bool`
|
||||||
|
|
||||||
|
HasArbitraryObject returns a boolean if a field has been set.
|
||||||
|
|
||||||
|
### GetArbitraryNullableObject
|
||||||
|
|
||||||
|
`func (o *User) GetArbitraryNullableObject() map[string]interface{}`
|
||||||
|
|
||||||
|
GetArbitraryNullableObject returns the ArbitraryNullableObject field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
|
### GetArbitraryNullableObjectOk
|
||||||
|
|
||||||
|
`func (o *User) GetArbitraryNullableObjectOk() (*map[string]interface{}, bool)`
|
||||||
|
|
||||||
|
GetArbitraryNullableObjectOk returns a tuple with the ArbitraryNullableObject field if it's non-nil, zero value otherwise
|
||||||
|
and a boolean to check if the value has been set.
|
||||||
|
|
||||||
|
### SetArbitraryNullableObject
|
||||||
|
|
||||||
|
`func (o *User) SetArbitraryNullableObject(v map[string]interface{})`
|
||||||
|
|
||||||
|
SetArbitraryNullableObject sets ArbitraryNullableObject field to given value.
|
||||||
|
|
||||||
|
### HasArbitraryNullableObject
|
||||||
|
|
||||||
|
`func (o *User) HasArbitraryNullableObject() bool`
|
||||||
|
|
||||||
|
HasArbitraryNullableObject returns a boolean if a field has been set.
|
||||||
|
|
||||||
|
### SetArbitraryNullableObjectNil
|
||||||
|
|
||||||
|
`func (o *User) SetArbitraryNullableObjectNil(b bool)`
|
||||||
|
|
||||||
|
SetArbitraryNullableObjectNil sets the value for ArbitraryNullableObject to be an explicit nil
|
||||||
|
|
||||||
|
### UnsetArbitraryNullableObject
|
||||||
|
`func (o *User) UnsetArbitraryNullableObject()`
|
||||||
|
|
||||||
|
UnsetArbitraryNullableObject ensures that no value is present for ArbitraryNullableObject, not even an explicit nil
|
||||||
|
### GetArbitraryTypeValue
|
||||||
|
|
||||||
|
`func (o *User) GetArbitraryTypeValue() interface{}`
|
||||||
|
|
||||||
|
GetArbitraryTypeValue returns the ArbitraryTypeValue field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
|
### GetArbitraryTypeValueOk
|
||||||
|
|
||||||
|
`func (o *User) GetArbitraryTypeValueOk() (*interface{}, bool)`
|
||||||
|
|
||||||
|
GetArbitraryTypeValueOk returns a tuple with the ArbitraryTypeValue field if it's non-nil, zero value otherwise
|
||||||
|
and a boolean to check if the value has been set.
|
||||||
|
|
||||||
|
### SetArbitraryTypeValue
|
||||||
|
|
||||||
|
`func (o *User) SetArbitraryTypeValue(v interface{})`
|
||||||
|
|
||||||
|
SetArbitraryTypeValue sets ArbitraryTypeValue field to given value.
|
||||||
|
|
||||||
|
### HasArbitraryTypeValue
|
||||||
|
|
||||||
|
`func (o *User) HasArbitraryTypeValue() bool`
|
||||||
|
|
||||||
|
HasArbitraryTypeValue returns a boolean if a field has been set.
|
||||||
|
|
||||||
|
### GetArbitraryNullableTypeValue
|
||||||
|
|
||||||
|
`func (o *User) GetArbitraryNullableTypeValue() interface{}`
|
||||||
|
|
||||||
|
GetArbitraryNullableTypeValue returns the ArbitraryNullableTypeValue field if non-nil, zero value otherwise.
|
||||||
|
|
||||||
|
### GetArbitraryNullableTypeValueOk
|
||||||
|
|
||||||
|
`func (o *User) GetArbitraryNullableTypeValueOk() (*interface{}, bool)`
|
||||||
|
|
||||||
|
GetArbitraryNullableTypeValueOk returns a tuple with the ArbitraryNullableTypeValue field if it's non-nil, zero value otherwise
|
||||||
|
and a boolean to check if the value has been set.
|
||||||
|
|
||||||
|
### SetArbitraryNullableTypeValue
|
||||||
|
|
||||||
|
`func (o *User) SetArbitraryNullableTypeValue(v interface{})`
|
||||||
|
|
||||||
|
SetArbitraryNullableTypeValue sets ArbitraryNullableTypeValue field to given value.
|
||||||
|
|
||||||
|
### HasArbitraryNullableTypeValue
|
||||||
|
|
||||||
|
`func (o *User) HasArbitraryNullableTypeValue() bool`
|
||||||
|
|
||||||
|
HasArbitraryNullableTypeValue returns a boolean if a field has been set.
|
||||||
|
|
||||||
|
### SetArbitraryNullableTypeValueNil
|
||||||
|
|
||||||
|
`func (o *User) SetArbitraryNullableTypeValueNil(b bool)`
|
||||||
|
|
||||||
|
SetArbitraryNullableTypeValueNil sets the value for ArbitraryNullableTypeValue to be an explicit nil
|
||||||
|
|
||||||
|
### UnsetArbitraryNullableTypeValue
|
||||||
|
`func (o *User) UnsetArbitraryNullableTypeValue()`
|
||||||
|
|
||||||
|
UnsetArbitraryNullableTypeValue ensures that no value is present for ArbitraryNullableTypeValue, not even an explicit nil
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
@ -24,6 +24,14 @@ type User struct {
|
|||||||
Phone *string `json:"phone,omitempty"`
|
Phone *string `json:"phone,omitempty"`
|
||||||
// User Status
|
// User Status
|
||||||
UserStatus *int32 `json:"userStatus,omitempty"`
|
UserStatus *int32 `json:"userStatus,omitempty"`
|
||||||
|
// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value.
|
||||||
|
ArbitraryObject *map[string]interface{} `json:"arbitraryObject,omitempty"`
|
||||||
|
// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value.
|
||||||
|
ArbitraryNullableObject map[string]interface{} `json:"arbitraryNullableObject,omitempty"`
|
||||||
|
// test code generation for any type Value can be any type - string, number, boolean, array or object.
|
||||||
|
ArbitraryTypeValue *interface{} `json:"arbitraryTypeValue,omitempty"`
|
||||||
|
// test code generation for any type Value can be any type - string, number, boolean, array, object or the 'null' value.
|
||||||
|
ArbitraryNullableTypeValue interface{} `json:"arbitraryNullableTypeValue,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewUser instantiates a new User object
|
// NewUser instantiates a new User object
|
||||||
@ -299,6 +307,136 @@ func (o *User) SetUserStatus(v int32) {
|
|||||||
o.UserStatus = &v
|
o.UserStatus = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetArbitraryObject returns the ArbitraryObject field value if set, zero value otherwise.
|
||||||
|
func (o *User) GetArbitraryObject() map[string]interface{} {
|
||||||
|
if o == nil || o.ArbitraryObject == nil {
|
||||||
|
var ret map[string]interface{}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return *o.ArbitraryObject
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArbitraryObjectOk returns a tuple with the ArbitraryObject field value if set, nil otherwise
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *User) GetArbitraryObjectOk() (*map[string]interface{}, bool) {
|
||||||
|
if o == nil || o.ArbitraryObject == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return o.ArbitraryObject, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasArbitraryObject returns a boolean if a field has been set.
|
||||||
|
func (o *User) HasArbitraryObject() bool {
|
||||||
|
if o != nil && o.ArbitraryObject != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetArbitraryObject gets a reference to the given map[string]interface{} and assigns it to the ArbitraryObject field.
|
||||||
|
func (o *User) SetArbitraryObject(v map[string]interface{}) {
|
||||||
|
o.ArbitraryObject = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArbitraryNullableObject returns the ArbitraryNullableObject field value if set, zero value otherwise (both if not set or set to explicit null).
|
||||||
|
func (o *User) GetArbitraryNullableObject() map[string]interface{} {
|
||||||
|
if o == nil {
|
||||||
|
var ret map[string]interface{}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return o.ArbitraryNullableObject
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArbitraryNullableObjectOk returns a tuple with the ArbitraryNullableObject field value if set, nil otherwise
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
||||||
|
func (o *User) GetArbitraryNullableObjectOk() (*map[string]interface{}, bool) {
|
||||||
|
if o == nil || o.ArbitraryNullableObject == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return &o.ArbitraryNullableObject, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasArbitraryNullableObject returns a boolean if a field has been set.
|
||||||
|
func (o *User) HasArbitraryNullableObject() bool {
|
||||||
|
if o != nil && o.ArbitraryNullableObject != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetArbitraryNullableObject gets a reference to the given map[string]interface{} and assigns it to the ArbitraryNullableObject field.
|
||||||
|
func (o *User) SetArbitraryNullableObject(v map[string]interface{}) {
|
||||||
|
o.ArbitraryNullableObject = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArbitraryTypeValue returns the ArbitraryTypeValue field value if set, zero value otherwise.
|
||||||
|
func (o *User) GetArbitraryTypeValue() interface{} {
|
||||||
|
if o == nil || o.ArbitraryTypeValue == nil {
|
||||||
|
var ret interface{}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return *o.ArbitraryTypeValue
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArbitraryTypeValueOk returns a tuple with the ArbitraryTypeValue field value if set, nil otherwise
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
func (o *User) GetArbitraryTypeValueOk() (*interface{}, bool) {
|
||||||
|
if o == nil || o.ArbitraryTypeValue == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return o.ArbitraryTypeValue, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasArbitraryTypeValue returns a boolean if a field has been set.
|
||||||
|
func (o *User) HasArbitraryTypeValue() bool {
|
||||||
|
if o != nil && o.ArbitraryTypeValue != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetArbitraryTypeValue gets a reference to the given interface{} and assigns it to the ArbitraryTypeValue field.
|
||||||
|
func (o *User) SetArbitraryTypeValue(v interface{}) {
|
||||||
|
o.ArbitraryTypeValue = &v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArbitraryNullableTypeValue returns the ArbitraryNullableTypeValue field value if set, zero value otherwise (both if not set or set to explicit null).
|
||||||
|
func (o *User) GetArbitraryNullableTypeValue() interface{} {
|
||||||
|
if o == nil {
|
||||||
|
var ret interface{}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return o.ArbitraryNullableTypeValue
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArbitraryNullableTypeValueOk returns a tuple with the ArbitraryNullableTypeValue field value if set, nil otherwise
|
||||||
|
// and a boolean to check if the value has been set.
|
||||||
|
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
||||||
|
func (o *User) GetArbitraryNullableTypeValueOk() (*interface{}, bool) {
|
||||||
|
if o == nil || o.ArbitraryNullableTypeValue == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return &o.ArbitraryNullableTypeValue, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasArbitraryNullableTypeValue returns a boolean if a field has been set.
|
||||||
|
func (o *User) HasArbitraryNullableTypeValue() bool {
|
||||||
|
if o != nil && o.ArbitraryNullableTypeValue != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetArbitraryNullableTypeValue gets a reference to the given interface{} and assigns it to the ArbitraryNullableTypeValue field.
|
||||||
|
func (o *User) SetArbitraryNullableTypeValue(v interface{}) {
|
||||||
|
o.ArbitraryNullableTypeValue = v
|
||||||
|
}
|
||||||
|
|
||||||
func (o User) MarshalJSON() ([]byte, error) {
|
func (o User) MarshalJSON() ([]byte, error) {
|
||||||
toSerialize := map[string]interface{}{}
|
toSerialize := map[string]interface{}{}
|
||||||
if o.Id != nil {
|
if o.Id != nil {
|
||||||
@ -325,6 +463,18 @@ func (o User) MarshalJSON() ([]byte, error) {
|
|||||||
if o.UserStatus != nil {
|
if o.UserStatus != nil {
|
||||||
toSerialize["userStatus"] = o.UserStatus
|
toSerialize["userStatus"] = o.UserStatus
|
||||||
}
|
}
|
||||||
|
if o.ArbitraryObject != nil {
|
||||||
|
toSerialize["arbitraryObject"] = o.ArbitraryObject
|
||||||
|
}
|
||||||
|
if o.ArbitraryNullableObject != nil {
|
||||||
|
toSerialize["arbitraryNullableObject"] = o.ArbitraryNullableObject
|
||||||
|
}
|
||||||
|
if o.ArbitraryTypeValue != nil {
|
||||||
|
toSerialize["arbitraryTypeValue"] = o.ArbitraryTypeValue
|
||||||
|
}
|
||||||
|
if o.ArbitraryNullableTypeValue != nil {
|
||||||
|
toSerialize["arbitraryNullableTypeValue"] = o.ArbitraryNullableTypeValue
|
||||||
|
}
|
||||||
return json.Marshal(toSerialize)
|
return json.Marshal(toSerialize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,12 +10,12 @@ Name | Type | Description | Notes
|
|||||||
**StringProp** | Pointer to **string** | | [optional]
|
**StringProp** | Pointer to **string** | | [optional]
|
||||||
**DateProp** | Pointer to **string** | | [optional]
|
**DateProp** | Pointer to **string** | | [optional]
|
||||||
**DatetimeProp** | Pointer to [**time.Time**](time.Time.md) | | [optional]
|
**DatetimeProp** | Pointer to [**time.Time**](time.Time.md) | | [optional]
|
||||||
**ArrayNullableProp** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ArrayNullableProp** | Pointer to **[]map[string]interface{}** | | [optional]
|
||||||
**ArrayAndItemsNullableProp** | Pointer to [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ArrayAndItemsNullableProp** | Pointer to **[]map[string]interface{}** | | [optional]
|
||||||
**ArrayItemsNullable** | [**[]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ArrayItemsNullable** | **[]map[string]interface{}** | | [optional]
|
||||||
**ObjectNullableProp** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ObjectNullableProp** | Pointer to **map[string]map[string]interface{}** | | [optional]
|
||||||
**ObjectAndItemsNullableProp** | Pointer to [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ObjectAndItemsNullableProp** | Pointer to **map[string]map[string]interface{}** | | [optional]
|
||||||
**ObjectItemsNullable** | [**map[string]map[string]interface{}**](map[string]interface{}.md) | | [optional]
|
**ObjectItemsNullable** | **map[string]map[string]interface{}** | | [optional]
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
@ -11,6 +11,10 @@ Name | Type | Description | Notes
|
|||||||
**password** | **str** | | [optional]
|
**password** | **str** | | [optional]
|
||||||
**phone** | **str** | | [optional]
|
**phone** | **str** | | [optional]
|
||||||
**user_status** | **int** | User Status | [optional]
|
**user_status** | **int** | User Status | [optional]
|
||||||
|
**arbitrary_object** | **bool, date, datetime, dict, float, int, list, str** | test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. | [optional]
|
||||||
|
**arbitrary_nullable_object** | **bool, date, datetime, dict, float, int, list, str, none_type** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [optional]
|
||||||
|
**arbitrary_type_value** | **object** | test code generation for any type Value can be any type - string, number, boolean, array or object. | [optional]
|
||||||
|
**arbitrary_nullable_type_value** | **object, none_type** | test code generation for any type Value can be any type - string, number, boolean, array, object or the 'null' value. | [optional]
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
@ -82,6 +82,10 @@ class User(ModelNormal):
|
|||||||
'password': (str,), # noqa: E501
|
'password': (str,), # noqa: E501
|
||||||
'phone': (str,), # noqa: E501
|
'phone': (str,), # noqa: E501
|
||||||
'user_status': (int,), # noqa: E501
|
'user_status': (int,), # noqa: E501
|
||||||
|
'arbitrary_object': (bool, date, datetime, dict, float, int, list, str,), # noqa: E501
|
||||||
|
'arbitrary_nullable_object': (bool, date, datetime, dict, float, int, list, str, none_type,), # noqa: E501
|
||||||
|
'arbitrary_type_value': (object,), # noqa: E501
|
||||||
|
'arbitrary_nullable_type_value': (object, none_type,), # noqa: E501
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -97,6 +101,10 @@ class User(ModelNormal):
|
|||||||
'password': 'password', # noqa: E501
|
'password': 'password', # noqa: E501
|
||||||
'phone': 'phone', # noqa: E501
|
'phone': 'phone', # noqa: E501
|
||||||
'user_status': 'userStatus', # noqa: E501
|
'user_status': 'userStatus', # noqa: E501
|
||||||
|
'arbitrary_object': 'arbitraryObject', # noqa: E501
|
||||||
|
'arbitrary_nullable_object': 'arbitraryNullableObject', # noqa: E501
|
||||||
|
'arbitrary_type_value': 'arbitraryTypeValue', # noqa: E501
|
||||||
|
'arbitrary_nullable_type_value': 'arbitraryNullableTypeValue', # noqa: E501
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -136,6 +144,10 @@ class User(ModelNormal):
|
|||||||
password (str): [optional] # noqa: E501
|
password (str): [optional] # noqa: E501
|
||||||
phone (str): [optional] # noqa: E501
|
phone (str): [optional] # noqa: E501
|
||||||
user_status (int): User Status. [optional] # noqa: E501
|
user_status (int): User Status. [optional] # noqa: E501
|
||||||
|
arbitrary_object (bool, date, datetime, dict, float, int, list, str): test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value.. [optional] # noqa: E501
|
||||||
|
arbitrary_nullable_object (bool, date, datetime, dict, float, int, list, str, none_type): test code generation for nullable objects. Value must be a map of strings to values or the 'null' value.. [optional] # noqa: E501
|
||||||
|
arbitrary_type_value (object): test code generation for any type Value can be any type - string, number, boolean, array or object.. [optional] # noqa: E501
|
||||||
|
arbitrary_nullable_type_value (object, none_type): test code generation for any type Value can be any type - string, number, boolean, array, object or the 'null' value.. [optional] # noqa: E501
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._data_store = {}
|
self._data_store = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user