Skip to content
This repository has been archived by the owner on Jul 2, 2019. It is now read-only.

Supporting x-nullable #112

Closed
philsturgeon opened this issue Jul 11, 2017 · 11 comments
Closed

Supporting x-nullable #112

philsturgeon opened this issue Jul 11, 2017 · 11 comments

Comments

@philsturgeon
Copy link

philsturgeon commented Jul 11, 2017

Swagger/OpenAPI are in a weird state between v2.0 and v3.0. There have been a few keywords added to v3.0 that probably should have been backported into a v2.1 or something. Instead the authors have quite adamantly shouted "No, this is coming in v3!" and everyone has been kinda stuck waiting, or using x- vendor prefixes which some things support and some don't.

You folks have done an awesome job supporting some of these x- vendor prefixes (like x-example), but there is another one: x-nullable.

Currently you don't support x-nullable, which leads to Dredd pronouncing things as invalid when they are not. A workaround has been suggested in apiaryio/dredd#283, suggesting that type: ['string', 'null'] will work. It doesn't.

(Maybe their renderer or parser-of-choice is lax enough to support it, but ReDoc and any strict parser will error.)

More on this here swagger-api/swagger-editor#1302

Instead, OpenAPI 3.0 will add nullable: true on the schema object. In the mean time, renderers and parsers are supporting x-nullable: true.

Example: Redocly/redoc#95

Supporting this field during this odd v2.0 / v3.0 gap would be amazing, and I can't get Dredd running at work until this is done.

@philsturgeon philsturgeon changed the title Supporting x-nullable Supporting nullable and example Jul 17, 2017
@philsturgeon
Copy link
Author

Updated description because I was crossing things over.

@philsturgeon philsturgeon changed the title Supporting nullable and example Supporting x-nullable Jul 17, 2017
@kylef
Copy link
Member

kylef commented Jul 17, 2017

I think it makes sense to support this, let me clear this with our product team and see if we can get this implemented soon. Thanks for the detailed report @philsturgeon.

@InfopactMLoos
Copy link

Any news on this?

@Marahin
Copy link

Marahin commented Nov 27, 2017

Bump, @kylef could you update us on the state of this issue?

@kylef
Copy link
Member

kylef commented Nov 27, 2017

I'd expect most of you are asking about this to use with Dredd. Right now Dredd is receiving the Swagger specific schema so to implement this feature we would need to craft JSON Schema's so that Dredd can use a JSON schema. JSON Schema supports multiple type so the produced JSON Schema should have a type of an array with null when nullable is present. This would be a larger task than I originally anticipated.

Alternatively, we could add support to Dredd for validating Swagger schemas which could include x-nullable.

@InfopactMLoos
Copy link

@kylef, Yes I think that is what is being described in this issue. Since your first option is probably a lot of work and because this repository is specifically focused on swagger and not JSON schema I don't think it is wise to change that.

What is being said is this new feature is being added in v3.0 of swagger only. Since upgrading this to swagger 3.0 is probably a lot of work we might implement what other tools are doing and that is allowing the vendor specific x-nullable. Since you announced forwarding this to your product team on July 17th I would expect some update by now. At the least some decision on whether or not this is on the roadmap? In any case, thank you looking into this.

@philsturgeon
Copy link
Author

philsturgeon commented Nov 28, 2017

Hey @kylef. Yeah It's a pain in the butt I know, but OpenAPI is not really JSON Schema as you probably know. OpenAPI v2 is 90% JSON Schema, and v3 is 99% JSON Schema, but this type issue is the largest remaining difference.

If a one-line hack could be added to dredd somehow, that says if (schema['x-nullable'] == true) types += null then I'd be completely happy.

Sure OAI3 has been out for a while now, but support is still really low. All of our stuff at WeWork is OAI2 whilst we wait on various tools to support OAI3 (like ReDoc, which has a 2.0.0-alpha1 supporting OAI3 yaaaay!) so this x-nullable support is still relevant.

Thanks for taking the time to look into this @kylef!

@scythargon
Copy link

This is still very needed, guys.

@honzajavorek
Copy link
Contributor

Re-opened until we bump fury version in dependencies.

@kylef kylef mentioned this issue Mar 15, 2018
@kylef
Copy link
Member

kylef commented Mar 26, 2018

@honzajavorek This issue is on the swagger adapter where it is fixed though. This isn't an issue tracker for Dredd.

@kylef kylef closed this as completed Mar 26, 2018
@honzajavorek
Copy link
Contributor

@kylef 🙀 I'm sorry! I thought I'm on a different repo 🙈

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants