forked from loafle/openapi-generator-original
Make nullable fix on all vars in Go (#8820)
* Make nullable fix on all vars in Go This applies the Nullable change to all variables on the model, instead of just the ones in vars. * Add sample showing the issue
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -387,7 +388,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (CodegenProperty param : model.vars) {
|
||||
for (CodegenProperty param : Iterables.concat(model.vars, model.allVars, model.requiredVars, model.optionalVars)) {
|
||||
param.vendorExtensions.put("x-go-base-type", param.dataType);
|
||||
if (!param.isNullable || param.isMap || param.isArray ||
|
||||
param.isFreeFormObject || param.isAnyType) {
|
||||
|
||||
@@ -1752,6 +1752,7 @@ components:
|
||||
boolean_prop:
|
||||
type: boolean
|
||||
nullable: true
|
||||
default: false
|
||||
string_prop:
|
||||
type: string
|
||||
nullable: true
|
||||
|
||||
@@ -1868,6 +1868,7 @@ components:
|
||||
nullable: true
|
||||
type: number
|
||||
boolean_prop:
|
||||
default: false
|
||||
nullable: true
|
||||
type: boolean
|
||||
string_prop:
|
||||
|
||||
@@ -6,7 +6,7 @@ Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**IntegerProp** | Pointer to **NullableInt32** | | [optional]
|
||||
**NumberProp** | Pointer to **NullableFloat32** | | [optional]
|
||||
**BooleanProp** | Pointer to **NullableBool** | | [optional]
|
||||
**BooleanProp** | Pointer to **NullableBool** | | [optional] [default to false]
|
||||
**StringProp** | Pointer to **NullableString** | | [optional]
|
||||
**DateProp** | Pointer to **NullableString** | | [optional]
|
||||
**DatetimeProp** | Pointer to **NullableTime** | | [optional]
|
||||
|
||||
@@ -37,6 +37,8 @@ type NullableClass struct {
|
||||
// will change when the set of required properties is changed
|
||||
func NewNullableClass() *NullableClass {
|
||||
this := NullableClass{}
|
||||
var booleanProp bool = false
|
||||
this.BooleanProp = *NewNullableBool(&booleanProp)
|
||||
return &this
|
||||
}
|
||||
|
||||
@@ -45,6 +47,8 @@ func NewNullableClass() *NullableClass {
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewNullableClassWithDefaults() *NullableClass {
|
||||
this := NullableClass{}
|
||||
var booleanProp bool = false
|
||||
this.BooleanProp = *NewNullableBool(&booleanProp)
|
||||
return &this
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user