Skip to content
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

How can I define how many digitis is allowed behind the comma? #1055

Closed
AraConnect opened this issue Oct 8, 2019 · 7 comments · Fixed by #1065
Closed

How can I define how many digitis is allowed behind the comma? #1055

AraConnect opened this issue Oct 8, 2019 · 7 comments · Fixed by #1065

Comments

@AraConnect
Copy link

How can I specify how many digitis is allowed for decimal part by using OAS 3.0/Redoc?

decimal(10,2) or NUMBER(10,2) means total length is 10 digits but out of 10 digits 2 digits are for decimal part. So the final allowed number will be 8 digits for integral part and 2 digits for fractional part.

@AraConnect AraConnect changed the title How to specify decimal (12,2)? How can I define how many digitis is allowed behind the comma? ex. decimal(10,2) Oct 8, 2019
@AraConnect AraConnect changed the title How can I define how many digitis is allowed behind the comma? ex. decimal(10,2) How can I define how many digitis is allowed behind the comma? Oct 8, 2019
@nanov
Copy link
Contributor

nanov commented Oct 8, 2019

type: number
multipleOf: 0.01

@AraConnect AraConnect reopened this Oct 8, 2019
@AraConnect
Copy link
Author

If I use mutipleOf it is not visible in the Redoc Document.

required:
    - name
properties:
    name:
        type: string
    tag:
        multipleOf: 0.01
        minimum: 0
        type: number

image

@nanov
Copy link
Contributor

nanov commented Oct 8, 2019

Well, this is already a ReDoc "issue".

EDIT
It's pretty easy to add to ReDoc, somewhere in this function.

The question is what should it display ( '* 0.01' for example ? ).

@AraConnect
Copy link
Author

AraConnect commented Oct 8, 2019

That is a good question. Something like decimals<= 2 digits.
or * 0.01

@nanov
Copy link
Contributor

nanov commented Oct 8, 2019

well, decimal 2 digits won't work, as you could also give multipleOf: 0.02 for example or even multipleOf: 2. Ie. this has other use cases also.

  • 0.01 or even multipleOf 0.01 could be an option.

@RomanHotsiy what is your opinion on this, i can implement it ?

@RomanHotsiy
Copy link
Member

I don't have a good idea of how to display this.

The current working idea is as below:

  • show decimals <= x digits for multipleOf with 0.1, 0.01, 0.001 etc..
  • show multiple of x for other cases

What do you think?

@nanov
Copy link
Contributor

nanov commented Oct 12, 2019

This is not a bad solution, splitting the cases.

I’ll implement something this weekend and we can take it from there.

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 a pull request may close this issue.

3 participants