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

Integer converted to long with C# class generation #595

Closed
brgrz opened this Issue Jan 10, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@brgrz

brgrz commented Jan 10, 2018

The following schema results in the following code

			"properties": {
				"pageSize": {
					"type": "integer",
					"default": 10,
					"minimum": 1
				},
				"pagingSize": {
					"type": "integer",
					"default": 5,
					"minimum": 1
				}
			},

        [Newtonsoft.Json.JsonProperty("pageSize", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
        [System.ComponentModel.DataAnnotations.Range(1, int.MaxValue)]
        public int PageSize { get; set; } = 10L;
    
        [Newtonsoft.Json.JsonProperty("pagingSize", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
        [System.ComponentModel.DataAnnotations.Range(1, int.MaxValue)]
        public int PagingSize { get; set; } = 5L;

which results in compile time error

"Cannot implicitly convert type 'long' to 'int'. An explicit conversion exists (are you missing a cast?)"

Is there a reason this is being treated as long when the type is explicitely set to integer in the schema?

@RSuter RSuter closed this in 465fb67 Jan 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment