forked from loafle/openapi-generator-original
fix: [csharp-netcore]: anyOf fixes for Primitive types (#13172)
* fixed null-coalescing operator incorrectly used for primitive types with the same change than @jafin in https://github.com/OpenAPITools/openapi-generator/pull/11427
This commit is contained in:
parent
3103b437b1
commit
1d8051e857
@ -1,3 +1,4 @@
|
||||
{{#model}}
|
||||
/// <summary>
|
||||
/// {{description}}{{^description}}{{classname}}{{/description}}
|
||||
/// </summary>
|
||||
@ -22,20 +23,22 @@
|
||||
}
|
||||
|
||||
{{/isNullable}}
|
||||
{{#anyOf}}
|
||||
{{#composedSchemas.anyOf}}
|
||||
{{^isNull}}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="{{classname}}" /> class
|
||||
/// with the <see cref="{{#lambdaCref}}{{{.}}}{{/lambdaCref}}" /> class
|
||||
/// with the <see cref="{{#lambdaCref}}{{{dataType}}}{{/lambdaCref}}" /> class
|
||||
/// </summary>
|
||||
/// <param name="actualInstance">An instance of {{{.}}}.</param>
|
||||
public {{classname}}({{{.}}} actualInstance)
|
||||
/// <param name="actualInstance">An instance of {{dataType}}.</param>
|
||||
public {{classname}}({{{dataType}}} actualInstance)
|
||||
{
|
||||
this.IsNullable = {{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}};
|
||||
this.IsNullable = {{#model.isNullable}}true{{/model.isNullable}}{{^model.isNullable}}false{{/model.isNullable}};
|
||||
this.SchemaType= "anyOf";
|
||||
this.ActualInstance = actualInstance{{^isNullable}} ?? throw new ArgumentException("Invalid instance found. Must not be null."){{/isNullable}};
|
||||
this.ActualInstance = actualInstance{{^model.isNullable}}{{^isPrimitiveType}} ?? throw new ArgumentException("Invalid instance found. Must not be null."){{/isPrimitiveType}}{{#isPrimitiveType}}{{#isArray}} ?? throw new ArgumentException("Invalid instance found. Must not be null."){{/isArray}}{{/isPrimitiveType}}{{#isPrimitiveType}}{{#isFreeFormObject}} ?? throw new ArgumentException("Invalid instance found. Must not be null."){{/isFreeFormObject}}{{/isPrimitiveType}}{{#isPrimitiveType}}{{#isString}} ?? throw new ArgumentException("Invalid instance found. Must not be null."){{/isString}}{{/isPrimitiveType}}{{/model.isNullable}};
|
||||
}
|
||||
|
||||
{{/anyOf}}
|
||||
{{/isNull}}
|
||||
{{/composedSchemas.anyOf}}
|
||||
|
||||
private Object _actualInstance;
|
||||
|
||||
@ -62,18 +65,20 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
{{#anyOf}}
|
||||
{{#composedSchemas.anyOf}}
|
||||
{{^isNull}}
|
||||
|
||||
/// <summary>
|
||||
/// Get the actual instance of `{{{.}}}`. If the actual instance is not `{{{.}}}`,
|
||||
/// Get the actual instance of `{{dataType}}`. If the actual instance is not `{{dataType}}`,
|
||||
/// the InvalidClassException will be thrown
|
||||
/// </summary>
|
||||
/// <returns>An instance of {{{.}}}</returns>
|
||||
public {{{.}}} Get{{{.}}}()
|
||||
/// <returns>An instance of {{dataType}}</returns>
|
||||
public {{{dataType}}} Get{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}{{#isArray}}{{#lambda.titlecase}}{{{dataFormat}}}{{/lambda.titlecase}}{{/isArray}}()
|
||||
{
|
||||
return ({{{.}}})this.ActualInstance;
|
||||
return ({{{dataType}}})this.ActualInstance;
|
||||
}
|
||||
{{/anyOf}}
|
||||
{{/isNull}}
|
||||
{{/composedSchemas.anyOf}}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
@ -233,3 +238,4 @@
|
||||
return false;
|
||||
}
|
||||
}
|
||||
{{/model}}
|
Loading…
x
Reference in New Issue
Block a user