-
Notifications
You must be signed in to change notification settings - Fork 37
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
fix "nullable" decoding #356
Conversation
Does the |
I didn't try OpenAPIKit30, but I can. Investigating your comment about removal of this feature lead me to this: OAI/OpenAPI-Specification#2244 It appears that the community is pretty confused about this. I don't know of OpenAPI and/or JSON Schema follow SemVer or not, but removing support for such a commonly used property in a dot release seems like an unwelcome change. There are many examples of openapi config files with the 3.1.0 version number still using nullable. See: https://github.com/search?type=code&q=path%3Aopenapi.json+nullable+3.1.0 and https://github.com/search?type=code&q=path%3Aopenapi.yaml+nullable+3.1.0 To me, this is an area where it is best to follow the "robustness principle". Maybe support with a warning is appropriate? |
Heads up, I had a lot to say here. Stick with my rambling if you don't mind, I have no ill will, just thoughts on maintaining tools like OpenAPIKit.
They don't. They documented this in their earliest RC release notes saying "As part of this release, we have decided to not follow SemVer anymore, and as such introduce breaking changes." I don't have a strong opinion on them deciding not to follow sem-ver, but then in other places they seem to be more wishy-washy about it:
The wishy-washiness and general community confusion seem to both lead to the conclusion that they didn't manage the release very well from a communication perspective if nothing else.
That's a tough sell for me. I want OpenAPIKit has always been strict on purpose because I want to help push the OpenAPI community in the direction of consistency, encouraging bug reports against non-conformant tools and encouraging fixes to non-conformant documents. I don't really want to be in the business of deciding which OpenAPI specification decisions (in this case All of that said, if a problem is big enough, I'm not going to ignore it. I might consider adding support for |
Ok, I dug into your linked GitHub searches and the issue opened against the OAS project. Granted your GitHub searches do find examples of non-conformant OAS 3.1 documents, but the linked GitHub issue seemed to be full of references to other projects where mostly maintainers were explaining why the project would switch from supporting |
I'm sensitive to all of your thoughts/points. Some specific comments below.
The robustness principle guidance would be to normalize on output. Yes, this violates the desire to preserve round-tripping, but it also helps your other goal:
If they don't support the type union syntax, they'll definitely get bug reports :) If OpenAPIKit don't support the schemas that are in the wild, folks are less likely to use it, and therefore less likely to be exposed to your preference for consistency.
I think that this one is pretty likely for the end-user to notice. Any decoder that expects a string for the type keyword would immediately hit an error or otherwise totally muck up and validation or code generator implementation.
I don't think this is the right thing to do simply in the name of round-tripping support, other than maybe by config/option if desired. My suggestion would be to relax the goal to: "OpenAPIKit should produce the same document it ingested modulo formatting for conforming schemas" and maybe to also add "and to produce warnings for any non-conforming schemes". |
I think I am beginning to lean more toward your proposal of allowing
I think this is potentially true, but not one of my bigger concerns. First of all, the ecosystem is small especially within a particular language like Swift. Second of all, I see other OAS implementations being strict as well so the choices out there that are less strict and still somewhat good drop-in replacements is even smaller yet. Lastly, I am a heavy user of this library myself, and when I would hit non-starters with OAS documents I was trying to use (because OpenAPIKit refused to decode them) I would just go off and create a fork of the document repository and a file a bug request with the author of that document. I'd switch to the fork and almost always see my bug request or PR resolved fairly quickly (at least by companies that truly wanted to support their OAS documents). This even happened a few times with big players like GitHub and they were always happy to fix their specifications. That's what I mean when I say I'd like to "help push the OpenAPI community:" I want to encourage people to help each other out with bug reports instead of shrugging their shoulders at a warning. Still, like I said at the top of this message, I think you are swaying me. I realize I am an idealist sometimes and in those cases I usually just need to see a conversation through like this one to start to change my mind. Give me a day. Would you be interested in adding that warning in this PR assuming I keep coming around to the idea? It'd be a bit of piping since the closest type with the |
I opened a PR against this branch that pipes the aforementioned warning through. If that sounds like what you were suggesting, go ahead and merge it and then we can merge this PR. ref. brandonbloom#1 |
Add a warning when decoding an OpenAPI 3.1 document that uses the nullable property.
That looks sensible to me. Thank you! Merged to this PR for further merging. |
The
"nullable"
keyword is inconsistently handled. Decoding logic exists, but when the"type"
keyword is recognized, the[..., "null"]
array pattern takes precedence. This change fixes that, so both work.