Skip to content

feat: make enum for numbers pass#646

Open
bfabio wants to merge 2 commits intoitalia:masterfrom
bfabio:enum
Open

feat: make enum for numbers pass#646
bfabio wants to merge 2 commits intoitalia:masterfrom
bfabio:enum

Conversation

@bfabio
Copy link
Copy Markdown
Member

@bfabio bfabio commented Oct 4, 2022

Make enum for number pass even when there's no minimum and maximum.

Also, allow enum only if minimum and maximum are not set.

Make `enum` for number pass even when there's no `minimum` and
`maximum`.

Also, allow `enum` only if `minimum` and `maximum` are not set.
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 4, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
api-oas-checker ❌ Failed (Inspect) Oct 4, 2022 at 2:27PM (UTC)

@bfabio
Copy link
Copy Markdown
Member Author

bfabio commented Oct 4, 2022

Some tests fail, but If this is good we can fix those and we can also do something similar to strings types.

Copy link
Copy Markdown
Contributor

@ioggstream ioggstream left a comment

Choose a reason for hiding this comment

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

  • max/min + enum is OK to me

minimum: 1
ko_EnumAndMinMax:
type: number
enum: [3]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can be syntactically valid to me. I could for example validate boundaries before checking the enumeration.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Makes sense.

We need to check if enum values are inside the min-max range though, I don't think it's possible with Spectral without a custom function.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@bfabio no need to push it that far for now. Probably spectral will do it for us in background today or tomorrow.

Co-authored-by: Roberto Polli <robipolli@gmail.com>
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