forked from loafle/openapi-generator-original
add readonly property support to C#
This commit is contained in:
parent
e9bb912fca
commit
890b7d17e3
@ -177,6 +177,9 @@ public class CodegenProperty {
|
|||||||
if (this.isEnum != other.isEnum) {
|
if (this.isEnum != other.isEnum) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this.isReadOnly != other.isReadOnly && (this.isReadOnly == null || !this.isReadOnly.equals(other.isReadOnly))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (this._enum != other._enum && (this._enum == null || !this._enum.equals(other._enum))) {
|
if (this._enum != other._enum && (this._enum == null || !this._enum.equals(other._enum))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,25 @@ namespace {{packageName}}.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
|
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public {{classname}}()
|
public {{classname}}({{#vars}}{{{dataType}}}{{name}} = null{{#hasMore}}, {{/hasMore}}{{/vars}})
|
||||||
{
|
{
|
||||||
{{#vars}}{{#defaultValue}}this.{{name}} = {{{defaultValue}}};
|
{{#vars}}{{#required}}if ({{name}} == null)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException("{{name}} is a required property for {{classname}} and cannot be null");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.{{name}} = {{name}};
|
||||||
|
}
|
||||||
|
{{/required}}{{/vars}}
|
||||||
|
{{#vars}}{{#defaultValue}}if ({{name}} == null)
|
||||||
|
{
|
||||||
|
this.{{name}} = {{{defaultValue}}};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.{{name}} = {{name}};
|
||||||
|
}
|
||||||
{{/defaultValue}}{{/vars}}
|
{{/defaultValue}}{{/vars}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +50,7 @@ namespace {{packageName}}.Model
|
|||||||
/// </summary>{{#description}}
|
/// </summary>{{#description}}
|
||||||
/// <value>{{{description}}}</value>{{/description}}
|
/// <value>{{{description}}}</value>{{/description}}
|
||||||
[DataMember(Name="{{baseName}}", EmitDefaultValue=false)]
|
[DataMember(Name="{{baseName}}", EmitDefaultValue=false)]
|
||||||
public {{{datatype}}} {{name}} { get; set; }
|
public {{{datatype}}} {{name}} { get; {{^isReadOnly}}set;{{/isReadOnly}} }
|
||||||
|
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
|
@ -1069,7 +1069,8 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int64"
|
"format": "int64",
|
||||||
|
"readOnly": true
|
||||||
},
|
},
|
||||||
"petId": {
|
"petId": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
@ -1304,6 +1304,13 @@ namespace IO.Swagger.Api
|
|||||||
}
|
}
|
||||||
// authentication (petstore_auth) required
|
// authentication (petstore_auth) required
|
||||||
|
|
||||||
|
// oauth required
|
||||||
|
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
||||||
|
{
|
||||||
|
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
||||||
|
}
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
|
||||||
// oauth required
|
// oauth required
|
||||||
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
||||||
{
|
{
|
||||||
@ -1404,6 +1411,14 @@ namespace IO.Swagger.Api
|
|||||||
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
|
||||||
|
// oauth required
|
||||||
|
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
||||||
|
{
|
||||||
|
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_,
|
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_,
|
||||||
@ -2033,6 +2048,13 @@ namespace IO.Swagger.Api
|
|||||||
}
|
}
|
||||||
// authentication (petstore_auth) required
|
// authentication (petstore_auth) required
|
||||||
|
|
||||||
|
// oauth required
|
||||||
|
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
||||||
|
{
|
||||||
|
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
||||||
|
}
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
|
||||||
// oauth required
|
// oauth required
|
||||||
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
||||||
{
|
{
|
||||||
@ -2133,6 +2155,14 @@ namespace IO.Swagger.Api
|
|||||||
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
|
||||||
|
// oauth required
|
||||||
|
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
||||||
|
{
|
||||||
|
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_,
|
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_,
|
||||||
|
@ -676,7 +676,6 @@ namespace IO.Swagger.Api
|
|||||||
|
|
||||||
|
|
||||||
// authentication (test_api_key_header) required
|
// authentication (test_api_key_header) required
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_header")))
|
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_header")))
|
||||||
{
|
{
|
||||||
headerParams["test_api_key_header"] = Configuration.GetApiKeyWithPrefix("test_api_key_header");
|
headerParams["test_api_key_header"] = Configuration.GetApiKeyWithPrefix("test_api_key_header");
|
||||||
@ -768,14 +767,12 @@ namespace IO.Swagger.Api
|
|||||||
|
|
||||||
|
|
||||||
// authentication (test_api_key_header) required
|
// authentication (test_api_key_header) required
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_header")))
|
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_header")))
|
||||||
{
|
{
|
||||||
headerParams["test_api_key_header"] = Configuration.GetApiKeyWithPrefix("test_api_key_header");
|
headerParams["test_api_key_header"] = Configuration.GetApiKeyWithPrefix("test_api_key_header");
|
||||||
}
|
}
|
||||||
|
|
||||||
// authentication (test_api_key_query) required
|
// authentication (test_api_key_query) required
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_query")))
|
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("test_api_key_query")))
|
||||||
{
|
{
|
||||||
queryParams["test_api_key_query"] = Configuration.GetApiKeyWithPrefix("test_api_key_query");
|
queryParams["test_api_key_query"] = Configuration.GetApiKeyWithPrefix("test_api_key_query");
|
||||||
|
@ -20,9 +20,10 @@ namespace IO.Swagger.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Category" /> class.
|
/// Initializes a new instance of the <see cref="Category" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Category()
|
public Category(Id = null, Name = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,9 +20,10 @@ namespace IO.Swagger.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Order" /> class.
|
/// Initializes a new instance of the <see cref="Order" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Order()
|
public Order(Id = null, PetId = null, Quantity = null, ShipDate = null, Status = null, Complete = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ namespace IO.Swagger.Model
|
|||||||
/// Gets or Sets Id
|
/// Gets or Sets Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||||
public long? Id { get; set; }
|
public long? Id { get; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -20,8 +20,25 @@ namespace IO.Swagger.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Pet" /> class.
|
/// Initializes a new instance of the <see cref="Pet" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Pet()
|
public Pet(Id = null, Category = null, Name = null, PhotoUrls = null, Tags = null, Status = null)
|
||||||
{
|
{
|
||||||
|
if (Name == null)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException("Name is a required property for Pet and cannot be null");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Name = Name;
|
||||||
|
}
|
||||||
|
if (PhotoUrls == null)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException("PhotoUrls is a required property for Pet and cannot be null");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.PhotoUrls = PhotoUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,10 @@ namespace IO.Swagger.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Tag" /> class.
|
/// Initializes a new instance of the <see cref="Tag" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Tag()
|
public Tag(Id = null, Name = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,9 +20,10 @@ namespace IO.Swagger.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="User" /> class.
|
/// Initializes a new instance of the <see cref="User" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public User()
|
public User(Id = null, Username = null, FirstName = null, LastName = null, Email = null, Password = null, Phone = null, UserStatus = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user