Skip to content

Conversation

@MikeEdgar
Copy link
Member

Remove incorrect mapping of number @Digits to pattern schema constraint and replace with multipleOf when not already set in the schema. Uses multipleOf: 1 for integers (i.e. Digits#fraction() <= 0) and multipleOf based on fraction value when > 0.

Fixes #2384

@MikeEdgar MikeEdgar added this to the 4.2.4 milestone Nov 21, 2025
@MikeEdgar
Copy link
Member Author

@Azquelt please take a look if you have a chance and let me know if anything here appears to you that it may conflict with the spirit of microprofile/microprofile-open-api#717.

@MikeEdgar
Copy link
Member Author

@Postremus FYI. Please take a look and give feedback if this looks amiss.

@sonarqubecloud
Copy link

Copy link
Collaborator

@Azquelt Azquelt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I don't see any conflicts with microprofile/microprofile-open-api#717

I've left a comment but my only other thoughts were additional things we could do:

  • We could infer minimum and maximum values based on Digits.integer if it's not otherwise constrained.
    • I'm a little uncertain on this since it's entirely possible the real constraint is tighter than @Digits suggests
    • although strictly speaking @Digits(integer = 6) implies "maxExclusive": 100000, "minExclusive": -100000, having that constraint might be worse than having no constraint documented if the actual constraint were e.g. 0 <= x < 65536
  • We could infer "multipleOf": 1 for integer types

@Postremus
Copy link
Contributor

@MikeEdgar looks good to me.

@MikeEdgar
Copy link
Member Author

We could infer minimum and maximum values based on Digits.integer if it's not otherwise constrained.

I considered this one too, but didn't do it here mainly for the reason you mentioned about being inaccurate. I suppose if @Digits is not scanned until after all of the possible min/max constraints, it should be fine.

We could infer "multipleOf": 1 for integer types

You mean when no @Digits is present at all? I think for the integer Java types we should be generating type: [ integer ] so it may be redundant.

@Azquelt
Copy link
Collaborator

Azquelt commented Nov 21, 2025

I think for the integer Java types we should be generating type: [ integer ] so it may be redundant.

Ah that's true, it would then be redundant.

@MikeEdgar
Copy link
Member Author

I've opened #2423 for the additional handling to set min/max constraints so we can think about that in the future and not block this fix/change for now.

@MikeEdgar MikeEdgar merged commit 7459d3f into smallrye:main Nov 22, 2025
12 checks passed
@MikeEdgar MikeEdgar deleted the issue-2384 branch November 22, 2025 11:25
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.

Automatically determine multipleOf from Digits constraint

3 participants