Skip to content

Conversation

@rbergheim
Copy link
Contributor

This is an attempt at generating C# Range annotations that supports more formats. My problem was that this property:

myProperty:
  type: integer
  format: int64
  minimum: 0

Generated this C# code:

[Newtonsoft.Json.JsonProperty("myProperty", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Range(0D, double.MaxValue)]
public long MyProperty { get; set; }

The code was defaulting to using double values if the format was not int32. In my example it should use 0L, long.MaxValue. Now it should use the correct suffixes and the correct max values.

@RicoSuter RicoSuter merged commit e9ed260 into RicoSuter:master Mar 29, 2025
@RicoSuter
Copy link
Owner

Thanks for the PR.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants