-
Notifications
You must be signed in to change notification settings - Fork 175
[V2 Code Generator] Fix validation method failure for optional properties #895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
894bdc5
[V2 Code Generator] Fix validation method failure for optional proper…
ShivangiReja f87e430
Remove unused operation
ShivangiReja ece227b
Make local `IsRequired` variable
ShivangiReja 3948893
Pass IVariable as a Parameter instead of valueReference
ShivangiReja 464f77c
Pass isNullable as a param
ShivangiReja 5ad546a
PR comment
ShivangiReja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| { | ||
| "swagger": "2.0", | ||
| "info": { | ||
| "version": "1.0.0", | ||
| "title": "Simple API", | ||
| "termsOfService": "http://helloreverb.com/terms/", | ||
| "contact": { | ||
| "email": "[email protected]" | ||
| }, | ||
| "license": { | ||
| "name": "Apache 2.0", | ||
| "url": "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
| } | ||
| }, | ||
| "host": "test.swagger.io", | ||
| "basePath": "/v2", | ||
| "schemes": [ | ||
| "http" | ||
| ], | ||
| "paths": {}, | ||
| "definitions": { | ||
| "DateAfterModification": { | ||
| "properties": { | ||
| "daysAfterModificationGreaterThan": { | ||
| "type": "number", | ||
| "multipleOf": 1.0, | ||
| "minimum": 0, | ||
| "description": "Value indicating the age in days after last modification" | ||
| }, | ||
| "daysAfterLastAccessTimeGreaterThan": { | ||
| "type": "number", | ||
| "multipleOf": 1.0, | ||
| "minimum": 0, | ||
| "description": "Value indicating the age in days after last blob access. This property can only be used in conjuction with last access time tracking policy" | ||
| } | ||
| }, | ||
| "description": "Object to define the number of days after object last modification Or last access. Properties daysAfterModificationGreaterThan and daysAfterLastAccessTimeGreaterThan are mutually exclusive" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // <auto-generated> | ||
| // Code generated by Microsoft (R) AutoRest Code Generator. | ||
| // Changes may cause incorrect behavior and will be lost if the code is | ||
| // regenerated. | ||
| // </auto-generated> | ||
|
|
||
| namespace Bug885 | ||
| { | ||
| using Models; | ||
| using Newtonsoft.Json; | ||
|
|
||
| /// <summary> | ||
| /// </summary> | ||
| public partial interface ISimpleAPI : System.IDisposable | ||
| { | ||
| /// <summary> | ||
| /// The base URI of the service. | ||
| /// </summary> | ||
| System.Uri BaseUri { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets json serialization settings. | ||
| /// </summary> | ||
| JsonSerializerSettings SerializationSettings { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets json deserialization settings. | ||
| /// </summary> | ||
| JsonSerializerSettings DeserializationSettings { get; } | ||
|
|
||
|
|
||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| // <auto-generated> | ||
| // Code generated by Microsoft (R) AutoRest Code Generator. | ||
| // Changes may cause incorrect behavior and will be lost if the code is | ||
| // regenerated. | ||
| // </auto-generated> | ||
|
|
||
| namespace Bug885.Models | ||
| { | ||
| using Microsoft.Rest; | ||
| using Newtonsoft.Json; | ||
| using System.Linq; | ||
|
|
||
| /// <summary> | ||
| /// Object to define the number of days after object last modification Or | ||
| /// last access. Properties daysAfterModificationGreaterThan and | ||
| /// daysAfterLastAccessTimeGreaterThan are mutually exclusive | ||
| /// </summary> | ||
| public partial class DateAfterModification | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the DateAfterModification class. | ||
| /// </summary> | ||
| public DateAfterModification() | ||
| { | ||
| CustomInit(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the DateAfterModification class. | ||
| /// </summary> | ||
| /// <param name="daysAfterModificationGreaterThan">Value indicating the | ||
| /// age in days after last modification</param> | ||
| /// <param name="daysAfterLastAccessTimeGreaterThan">Value indicating | ||
| /// the age in days after last blob access. This property can only be | ||
| /// used in conjuction with last access time tracking policy</param> | ||
| public DateAfterModification(double? daysAfterModificationGreaterThan = default(double?), double? daysAfterLastAccessTimeGreaterThan = default(double?)) | ||
| { | ||
| DaysAfterModificationGreaterThan = daysAfterModificationGreaterThan; | ||
| DaysAfterLastAccessTimeGreaterThan = daysAfterLastAccessTimeGreaterThan; | ||
| CustomInit(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// An initialization method that performs custom operations like setting defaults | ||
| /// </summary> | ||
| partial void CustomInit(); | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets value indicating the age in days after last | ||
| /// modification | ||
| /// </summary> | ||
| [JsonProperty(PropertyName = "daysAfterModificationGreaterThan")] | ||
| public double? DaysAfterModificationGreaterThan { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets value indicating the age in days after last blob | ||
| /// access. This property can only be used in conjuction with last | ||
| /// access time tracking policy | ||
| /// </summary> | ||
| [JsonProperty(PropertyName = "daysAfterLastAccessTimeGreaterThan")] | ||
| public double? DaysAfterLastAccessTimeGreaterThan { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Validate the object. | ||
| /// </summary> | ||
| /// <exception cref="ValidationException"> | ||
| /// Thrown if validation fails | ||
| /// </exception> | ||
| public virtual void Validate() | ||
| { | ||
| if (DaysAfterModificationGreaterThan != null) | ||
| { | ||
| if (DaysAfterModificationGreaterThan < 0) | ||
| { | ||
| throw new ValidationException(ValidationRules.InclusiveMinimum, "DaysAfterModificationGreaterThan", 0); | ||
| } | ||
| if (DaysAfterModificationGreaterThan % 1 != 0) | ||
| { | ||
| throw new ValidationException(ValidationRules.MultipleOf, "DaysAfterModificationGreaterThan", 1); | ||
| } | ||
| } | ||
| if (DaysAfterLastAccessTimeGreaterThan != null) | ||
| { | ||
| if (DaysAfterLastAccessTimeGreaterThan < 0) | ||
| { | ||
| throw new ValidationException(ValidationRules.InclusiveMinimum, "DaysAfterLastAccessTimeGreaterThan", 0); | ||
| } | ||
| if (DaysAfterLastAccessTimeGreaterThan % 1 != 0) | ||
| { | ||
| throw new ValidationException(ValidationRules.MultipleOf, "DaysAfterLastAccessTimeGreaterThan", 1); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| // <auto-generated> | ||
| // Code generated by Microsoft (R) AutoRest Code Generator. | ||
| // Changes may cause incorrect behavior and will be lost if the code is | ||
| // regenerated. | ||
| // </auto-generated> | ||
|
|
||
| namespace Bug885 | ||
| { | ||
| using Microsoft.Rest; | ||
| using Microsoft.Rest.Serialization; | ||
| using Models; | ||
| using Newtonsoft.Json; | ||
| using System.Collections; | ||
| using System.Collections.Generic; | ||
| using System.Net; | ||
| using System.Net.Http; | ||
|
|
||
| public partial class SimpleAPI : ServiceClient<SimpleAPI>, ISimpleAPI | ||
| { | ||
| /// <summary> | ||
| /// The base URI of the service. | ||
| /// </summary> | ||
| public System.Uri BaseUri { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets json serialization settings. | ||
| /// </summary> | ||
| public JsonSerializerSettings SerializationSettings { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets json deserialization settings. | ||
| /// </summary> | ||
| public JsonSerializerSettings DeserializationSettings { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the SimpleAPI class. | ||
| /// </summary> | ||
| /// <param name='httpClient'> | ||
| /// HttpClient to be used | ||
| /// </param> | ||
| /// <param name='disposeHttpClient'> | ||
| /// True: will dispose the provided httpClient on calling SimpleAPI.Dispose(). False: will not dispose provided httpClient</param> | ||
| public SimpleAPI(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) | ||
| { | ||
| Initialize(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the SimpleAPI class. | ||
| /// </summary> | ||
| /// <param name='handlers'> | ||
| /// Optional. The delegating handlers to add to the http client pipeline. | ||
| /// </param> | ||
| public SimpleAPI(params DelegatingHandler[] handlers) : base(handlers) | ||
| { | ||
| Initialize(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the SimpleAPI class. | ||
| /// </summary> | ||
| /// <param name='rootHandler'> | ||
| /// Optional. The http client handler used to handle http transport. | ||
| /// </param> | ||
| /// <param name='handlers'> | ||
| /// Optional. The delegating handlers to add to the http client pipeline. | ||
| /// </param> | ||
| public SimpleAPI(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) | ||
| { | ||
| Initialize(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the SimpleAPI class. | ||
| /// </summary> | ||
| /// <param name='baseUri'> | ||
| /// Optional. The base URI of the service. | ||
| /// </param> | ||
| /// <param name='handlers'> | ||
| /// Optional. The delegating handlers to add to the http client pipeline. | ||
| /// </param> | ||
| /// <exception cref="System.ArgumentNullException"> | ||
| /// Thrown when a required parameter is null | ||
| /// </exception> | ||
| public SimpleAPI(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) | ||
| { | ||
| if (baseUri == null) | ||
| { | ||
| throw new System.ArgumentNullException("baseUri"); | ||
| } | ||
| BaseUri = baseUri; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the SimpleAPI class. | ||
| /// </summary> | ||
| /// <param name='baseUri'> | ||
| /// Optional. The base URI of the service. | ||
| /// </param> | ||
| /// <param name='rootHandler'> | ||
| /// Optional. The http client handler used to handle http transport. | ||
| /// </param> | ||
| /// <param name='handlers'> | ||
| /// Optional. The delegating handlers to add to the http client pipeline. | ||
| /// </param> | ||
| /// <exception cref="System.ArgumentNullException"> | ||
| /// Thrown when a required parameter is null | ||
| /// </exception> | ||
| public SimpleAPI(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) | ||
| { | ||
| if (baseUri == null) | ||
| { | ||
| throw new System.ArgumentNullException("baseUri"); | ||
| } | ||
| BaseUri = baseUri; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// An optional partial-method to perform custom initialization. | ||
| ///</summary> | ||
| partial void CustomInitialize(); | ||
| /// <summary> | ||
| /// Initializes client properties. | ||
| /// </summary> | ||
| private void Initialize() | ||
| { | ||
| BaseUri = new System.Uri("http://test.swagger.io/v2"); | ||
| SerializationSettings = new JsonSerializerSettings | ||
| { | ||
| Formatting = Newtonsoft.Json.Formatting.Indented, | ||
| DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, | ||
| DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, | ||
| NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, | ||
| ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, | ||
| ContractResolver = new ReadOnlyJsonContractResolver(), | ||
| Converters = new List<JsonConverter> | ||
| { | ||
| new Iso8601TimeSpanConverter() | ||
| } | ||
| }; | ||
| DeserializationSettings = new JsonSerializerSettings | ||
| { | ||
| DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, | ||
| DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, | ||
| NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, | ||
| ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, | ||
| ContractResolver = new ReadOnlyJsonContractResolver(), | ||
| Converters = new List<JsonConverter> | ||
| { | ||
| new Iso8601TimeSpanConverter() | ||
| } | ||
| }; | ||
| CustomInitialize(); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.