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

Supporting x-nullable #112

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

Comments

Projects
None yet
6 participants
@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: Rebilly/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

This comment has been minimized.

Copy link

philsturgeon commented Jul 17, 2017

Updated description because I was crossing things over.

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

@kylef kylef added the enhancement label Jul 17, 2017

@kylef

This comment has been minimized.

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

This comment has been minimized.

Copy link

InfopactMLoos commented Nov 7, 2017

Any news on this?

@Marahin

This comment has been minimized.

Copy link

Marahin commented Nov 27, 2017

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

@kylef

This comment has been minimized.

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

This comment has been minimized.

Copy link

InfopactMLoos commented Nov 28, 2017

@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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

scythargon commented Mar 9, 2018

This is still very needed, guys.

@honzajavorek

This comment has been minimized.

Copy link
Member

honzajavorek commented Mar 14, 2018

Re-opened until we bump fury version in dependencies.

@kylef kylef referenced this issue Mar 15, 2018

Merged

Release 0.18.0 #163

@kylef

This comment has been minimized.

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 Mar 26, 2018

@honzajavorek

This comment has been minimized.

Copy link
Member

honzajavorek commented Mar 27, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment