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

problem with oneOf: string/integer #286

Open
jcoyne opened this issue Sep 21, 2020 · 2 comments · May be fixed by #301
Open

problem with oneOf: string/integer #286

jcoyne opened this issue Sep 21, 2020 · 2 comments · May be fixed by #301

Comments

@jcoyne
Copy link
Contributor

jcoyne commented Sep 21, 2020

I have added a rails application here that illustrates the problem: https://github.com/jcoyne/comittee-bug

It has a failing test which you can run by doing:

bundle exec rspec spec/requests/resources_request_spec.rb

Committee reports{"id":"bad_request","message":"7116 isn't one of in #/components/schemas/Title/properties/value"}

I believe this is because of: https://github.com/jcoyne/comittee-bug/blob/master/openapi.yml#L32-L34

If I comment out the line:

          - type: integer

then it works fine.

If I change this line of the test:

https://github.com/jcoyne/comittee-bug/blob/master/spec/requests/resources_request_spec.rb#L6

to look like a string, e.g. ({ "title":{"value":"Number 7116"}}) it also works fine.

@ota42y
Copy link
Member

ota42y commented Oct 14, 2020

I understand this bug.

committee convert string to integer for form parameters (the values are send as strings by browser) so it caused this bug.

For example, we use this schema.

oneOf:
  - type: string
  - type: integer

When we send the string value which can't convert integer (like true),
type: string validation succeeded and 'type: integer' validation failed so match 'oneOf'.

But, when we send string value which can convert integer (like '42'),
both validation succeeded... so the parameter doesn't match 'oneOf' ( few validation succeeded... )

When the request is 'application/json', we don't convert the value (without 'date-time' convert)

Ok, I'm going to fix 🙋

@jcoyne
Copy link
Contributor Author

jcoyne commented Oct 14, 2020

Oh, yeah, that's tricky. Thanks @ota42y!

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.

2 participants