Conversation
Changes Unknown when pulling 2d6b764 on meytal127:master into ** on BigstickCarpet:master**. |
Hi @meytal127. Thanks for the PR, but can you please explain the issue that it fixes? It's not clear to me why there should be special handling of |
Hi @BigstickCarpet, Without the fix we receive the following error:
|
Changes Unknown when pulling 9a689f6 on meytal127:master into ** on BigstickCarpet:master**. |
@meytal127 - Ah, I see what you're talking about. However, there are two problems with this fix.
|
Thanks for the reply.
So what do you think the solution should be? How should we treat null
values?
בתאריך 11 ביולי 2017 15:12, "James Messinger" <notifications@github.com>
כתב:
@meytal127 <https://github.com/meytal127> - Ah, I see what you're talking
about. However, there are two problems with this fix.
1.
It only fixes it for type: "object", not for other types, which would be
inconsistent and confusing behavior
2.
The Swagger 2.0 spec does not allow nullable fields
<swagger-api/swagger-node#399> for any type,
including objects. I'm currently working on adding support for OpenAPI
3.0
<https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.md>,
which *does* support nullable fields.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#92 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/APVU3W_hCOrBNY-Vu3df8PYU2-Tg1kW9ks5sM2aYgaJpZM4OS8GX>
.
|
@meytal127 - You can workaround this using standard Express middleware. You could add a middleware function to remove any null fields from the request body before the Here's a sample API that reproduces the problem you're experiencing: https://runkit.com/bigstickcarpet/swagger-express-middleware-pr-92/1.0.0 You can send a curl -X POST \
https://swagger-express-middleware-pr-92-nr9aw9u4ye5j.runkit.sh/ \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"name": "Fido",
"type": "dog",
"address": null
}' When you run that command, you get the following error response, due to the
Now, compare that to this API, which is the same as the previous one, but with some error-handling middleware added after the You can send a curl -X POST \
https://swagger-express-middleware-pr-92-hffies7jjrq0.runkit.sh/ \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"name": "Fido",
"type": "dog",
"address": null
}' And when you run that command, you'll see that it now succeeds. This is because I "caught" the null-field error and ignored it. |
@BigstickCarpet Thank you for the answer! |
Hi,
|
when an object value is null