-
Notifications
You must be signed in to change notification settings - Fork 6
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
Validation fails when for array saying it is an object #19
Comments
Hello @amplexdenmark, thanks for your feedback, here is the mentioned case to discuess:
We can see that |
Hello @xinz Exactly that is the question. Where does the "_json" wrapper come from. The example I'am using is extremely simple, my mix.exs depends is:
You gave seen my oas3 definition above, and the application.ex is just:
That is all. I then test using curl like this: So to me it looks like Oasis adds that wrapper but it could of course be Plug Cowboy. |
Yes, it is added by |
Great, thanks, I will continue to investigate. |
I'm not sure that last analysis is correct though, but my debugger indicates it. |
@amplexdenmark Currently, there uses |
Well, I think that the function Actually it is because |
Not sure the unwrapping should be in |
So you think we need to unwrap |
Yes, otherwise oasis can only validate json with objects. |
I see, I will try it, thanks again for your help. |
hello @amplexdenmark, we have a PR to resolve this issue, could you please check with the latest |
FYI, I have gotten a PR accepted for Plug.Parsers.JSON This introduces an option for Plug.Parsers: |
I have now checked the latest branch and it looks good :) Only thing I noticed is that a recursive validation is not performed. Likewise for an object, it is validated that an object is received, but not that it is the correct type. For the above example both these curl commands validates correctly, not just the first one.
|
Hello, Since this above spec definition does not define a
I tested it works as expected, could you double check use the example like this?
|
Hello, My bad, of course I need the "required", however the correct syntax is So to me, this issue is now resolved. Thank you for the collaboration |
FYI, Currently, it heavily leverages 1, Thanks clarify, yes, the correct syntax is |
Released in 0.5.1 |
Hi again
Now that the validation is running for my POST request, I have run into the next issue.
When I POST an array as specified, I get:
Failed to validate JSON schema with an error: Type mismatch. Expected Array but got Object.
In line: 66 in Oasis.Validator the
value = %{"_json" => [%{"id" => 1, "name" => "SH"}]}
This leads to the call to
ExJsonSchema.Validator.validate
in line 99 to fail, because the passed in value is not aList
It should only be the value for the key
"_json"
that should be passed into ExJsonSchema.Validator.validateMy oas definition is:
and I test using this data:
[{"id":1,"name":"SH"}]
The text was updated successfully, but these errors were encountered: