openapi-core icon indicating copy to clipboard operation
openapi-core copied to clipboard

Nullable field or schema not validating for None

Open diogobaeder opened this issue 4 years ago • 12 comments

Hi,

I've just upgrade openapi-core on my project to 0.13.3, after some months without upgrading, and now nullable schemas are not validating None values anymore.

I found a commit which seems to fix the issue: https://github.com/p1c2u/openapi-core/commit/7307794656106323b1f46cebd7525fcb265f5f28 - but this seems to have been fixed after the latest tag.

Can you release a new patch version, with the most recent fixes, please? I use nullable schemas quite a lot, and need that fix...

Thanks!

diogobaeder avatar Jun 04 '20 06:06 diogobaeder

Actually, just since I already created this ticket, there's a very similar issue still going on in the latest version from master: nullable arrays don't work, if I pass None it just fails instead of accepting the value. The reason is, the ArrayUnmarshaller tries to list(map(self.items_unmarshaller, value)) when the value is None, hence raising a NoneType error.

diogobaeder avatar Jun 04 '20 07:06 diogobaeder

Reproducing the same issue.

Unfortunately, this project going to be dead soon (I would say), it seems that author has no time at all, which is fully understandable, but if there is no release for longer time for some already fixed issues, not sure is it worth to contribute here at all (I usually fix issue locally, but that's not it).

If I got time, I will try to create PR for this.

stojan-jovic avatar Jul 13 '20 13:07 stojan-jovic

I wouldn't say the project is "going to be dead soon"; It's just that the author, @p1c2u , hasn't been much active on it, but recently I got some replies on tickets here. Maybe it's worth considering adding more people as direct collaborators of the project.

diogobaeder avatar Jul 13 '20 17:07 diogobaeder

Maybe it's worth considering adding more people as direct collaborators of the project.

That's the key! Without that, there is no too much sense in providing fixes without possibility to release, even potential smaller issues are better than issue with paths resolving. In any case, when (i.e. if) that happens, I'm here to help with PRs.

stojan-jovic avatar Jul 13 '20 21:07 stojan-jovic

Looks like a new tag was cut in July, so this issue is moot? https://github.com/p1c2u/openapi-core/commit/0aeb14477bd881247856a8ab520b5adf4223573d

matt2000 avatar Oct 12 '20 19:10 matt2000

I do not think that fix for this issue is included in the last release, but you can check.

stojan-jovic avatar Oct 12 '20 21:10 stojan-jovic

To correct myself (from previous comment) - handling nullable is partially fixed in the latest release (0.13.4), but still having two issues:

  • When nullable is set for arrays (i.e. type: array & nullable: true), null value not being properly validated, instead, it raising error: 'NoneType' object is not iterable. So, the same issue that diogobaeder reported in the second post.
  • When nullable is set for date-time (i.e. type: string, format: date-time & nullable: true), null value sometimes not being properly validated, instead, it raising error: Parser must be a string or character stream, not NoneType. So, validating null value for date-times working fine in some cases, but not in others (when it raising mentioned error). Still not sure what is the root cause of such behavior (if I figure out, will report that here).

stojan-jovic avatar Dec 01 '20 15:12 stojan-jovic

@stojan-jovic I address the first case in #276.

What do we think ?

jgod avatar Jan 13 '21 01:01 jgod

any news on this issue?

srgkm avatar Feb 01 '21 11:02 srgkm

This is still an issue: "message": "None for not nullable"

fajfer avatar Jan 20 '22 09:01 fajfer

Still an issue. I just updated openapi-core in my project and all of a sudden I started getting that error for a schema model that is nullable. This is the schema, with the description simplified:

{'description': 'something something.',
     'format': 'uuid',
     'nullable': True,
     'type': 'string'}

This leads me to:

None is not of type 'string'

diogobaeder avatar Nov 17 '22 00:11 diogobaeder

Almost same error for:

    {'additionalProperties': True,
     'description': 'something something.',
     'nullable': True,
     'type': 'object'}

and almost the same for:

{'format': 'date-time', 'nullable': True, 'type': 'string'}

I see this as a pretty big issue on the current version.

diogobaeder avatar Nov 17 '22 01:11 diogobaeder