Skip to content

Refined types for Integer and Numbers are specced as inclusive bounds, but converters and compilers treat it inconsitently #586

@ZzAve

Description

@ZzAve

Describe the bug
The documentation on refined types is not really clear on how bounds in refined types are treated.
https://wirespec.io/docs/language/types#refined

For example, if we have

type IntegerBetweenTwoAndFive = Integer(2,5)

Which integer values are considered to be valid? 2, 3, 4, 5?

The implementation of the emitters seems to be somewhat unclear about it too:

  • Kotlin --> 3, 4 .. both bounds are exclusive
  • Java --> same
  • Typescript --> same
  • Python --> ??
  • OpenAPIV2 --> 2,3,4,5 .. both bounds are inclusive
  • OpenAPIV3 --> same

I believe the Wirespec language should be clear about this, whether or not these bounds are inclusive or not. Conceptually, it makes the most sense to make them inclusive, as that is also the default in most other languages (e.g. OpenAPI).

To Reproduce
Steps to reproduce the behavior:

  1. Create a wirespec file:
type AnIntegerType = Integer(_,1)
type ANumberType = Number(_,1.0)
  1. Compile or convert into various languages
  2. Observe
    Expected behavior

Consistent use of lower and upper bounds

Actual behavior

Inconsistent use of lower and upper bounds

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions