You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
you're right, this a Drafter issue. Drafter compiles JSON schema from MSON and this JSON schema is used for Gavel validation of server response. Since this feature will be introduced in Drafter it's only a matter of bumping Drafter version in Dredd to support it.
Awesome! @pksunkara when can can we expect a new release of drafter? I know nullable is in the master branch since I was so involved in that, but it seems that we need a new tag release so that Dredd can point specifically to that.
Unfortunately, we can't announce nullable support until apiaryio/drafter#121 is done. But other than that, we have a bit of work currently happening after which there will be a new drafter release.
I think I have my confusion figured out @netmilk... Dredd uses drafter.js which is a wrapper (?) for protagonist which uses drafter via a git module. Right?
@netmilk I'm running into some difficulty right now testing an update to dredd so that it will use drafter.js and the latest (currently master branch) version of drafter. I have a feeling this may be because (as @pksunkara) dredd needs to use protagonist 1.x directly and eliminate the reference to drafter.js.
My question is how complex or simple do you think that will be, and what are the blockers preventing it from happening?
I have a high priority issue right now with the project I am on that we cannot properly test our API with dredd due to the null limitations, I've been working closly with @pksunkara to implement this on MSON, snowcrash, and drafter, now that that is close to complete dredd is the next focus of my attention. I can help out on this, I just need to know what the blockers are so I can tackle them.
Mainly, thank you very much for all your enthusiasm and and contributions but at this moment, updating to the latest protagonist won't solve your issue with nullable parameter. Drafter (not .js) used in the latest protagonist doesn't have feature parity with drafter.js (yes, .js) which supports JSON schema rendering from MSONs. Updating to the protagonist would cause complete disabling of validation of MSON structures in Dredd.
@zdne confirmed the Blueprint team is working on support of JSON schema rendering in the Drafter (not .js) used in the latest protagonist and they are treating it as a priority.
If this is a limitation for using Dredd in your actual project, I would propose some workaround in beforeAll hooks where you can modify the generated schema in the transaction object under the expected.body.schema property.
Hi @netmilk, thank you for your reply. Yes, this may be a limitation, so I will have to look into your suggested work around.
Regarding protagonist, drafter, and drafter.js... Let me see if I fully understand this.
Dredd (latest release) uses Drafter.js (latest release), which uses Protagonist (older 0.x release), which finally uses Dredd (older release again).
The latest version of Protagonist (1.x) uses a newer version of Dredd (not the latest though), however this results in a different feature set than what Dredd.js (using 0.x Protagonist) provides? Because of this my attempts to migrate Dredd to Protagonist 1.x and eliminate Drafter.js is actually a very large task that will not solve my original issues.
Adding all that together, I am seeing that the latest version of Drafter does have the features I need, and the scheduled 1.1.0 release of Drafter will also include 'nullable'. So this is a rough outline of what has to happen before Dredd can properly support nullable
1.1.0 release of Drafter
Protagonist updated to 1.1.0 version of drafter
Dredd updated to use the above mentioned release of Protagonist
Does all that sound about right? Sorry, if I am way off.
If I am actually correct, then I think I need to work with @zdne currently to get the 1.1.0 release of Drafter taken care of, and then Protagonist updated to use that. Then I can return to Dredd.
It still fails with the error fail: body: At '/price_per_seat_cents' Invalid type: null (expected number). I'm using dredd @ 1.0.1. I've also tried making expected.bodySchema.price_per_seate_cents.type = 'number,nullable' and it didn't seem to work.
For those who just want there tests to work when a response returns null for a field just change the type in the specification from.
id:
type: integerdescription: The ID of something.minimum: 0
To the following.
id:
type:
- integer
- 'null'description: The ID of something.minimum: 0
Your Dredd tests should now accept null for the field.
EDIT: Don't do this although it passes validation its technically not valid and breaks tools like swagger-codegen
The x-nullable extension attribute is the way to go, I just need to find I way to make the tests pass in the same way it does when defining type: ['integer', null].
The x-nullable extension attribute is the way to go, I just need to find I way to make the tests pass in the same way it does when defining type: ['integer', null].
@InfopactMLoos Looks like you're hitting a bug because x-nullable is not being applied recursively (only at root of the schema). I've fixed this in apiaryio/fury-adapter-swagger#172, hopefully we can get this reviewed tomorrow and released into production/Dredd.
Activity
netmilk commentedon Sep 29, 2015
Hi @obihann,
you're right, this a Drafter issue. Drafter compiles JSON schema from MSON and this JSON schema is used for Gavel validation of server response. Since this feature will be introduced in Drafter it's only a matter of bumping Drafter version in Dredd to support it.
obihann commentedon Sep 29, 2015
Awesome! @pksunkara when can can we expect a new release of drafter? I know nullable is in the master branch since I was so involved in that, but it seems that we need a new tag release so that Dredd can point specifically to that.
pksunkara commentedon Sep 29, 2015
Unfortunately, we can't announce nullable support until apiaryio/drafter#121 is done. But other than that, we have a bit of work currently happening after which there will be a new drafter release.
obihann commentedon Sep 29, 2015
@pksunkara thanks, I'll try to take a look at that tonight and help you guys out a bit.
@netmilk I just want to verify all that is holding this up is in fact apiaryio/drafter, I ask this because I understood dredd uses apiaryio/drafter.js (which is being replaced by apiaryio/protagonist)?
obihann commentedon Sep 29, 2015
I think I have my confusion figured out @netmilk... Dredd uses drafter.js which is a wrapper (?) for protagonist which uses drafter via a git module. Right?
pksunkara commentedon Sep 29, 2015
Dredd uses drafter.js which uses protagonist 0.x. We need to move dredd to protagonist 1.x.
obihann commentedon Sep 29, 2015
That makes perfect sense, thanks. I'm kind of afraid to ask but what is waiting on moving dredd to protagonist 1.x?
Thanks.
pksunkara commentedon Sep 29, 2015
I think @netmilk will be more suited to answer this.
obihann commentedon Sep 29, 2015
Sounds good, thanks.
obihann commentedon Sep 30, 2015
@netmilk I'm running into some difficulty right now testing an update to dredd so that it will use drafter.js and the latest (currently master branch) version of drafter. I have a feeling this may be because (as @pksunkara) dredd needs to use protagonist 1.x directly and eliminate the reference to drafter.js.
My question is how complex or simple do you think that will be, and what are the blockers preventing it from happening?
I have a high priority issue right now with the project I am on that we cannot properly test our API with dredd due to the null limitations, I've been working closly with @pksunkara to implement this on MSON, snowcrash, and drafter, now that that is close to complete dredd is the next focus of my attention. I can help out on this, I just need to know what the blockers are so I can tackle them.
netmilk commentedon Oct 2, 2015
Hi @obihann,
Mainly, thank you very much for all your enthusiasm and and contributions but at this moment, updating to the latest protagonist won't solve your issue with nullable parameter. Drafter (not .js) used in the latest protagonist doesn't have feature parity with drafter.js (yes, .js) which supports JSON schema rendering from MSONs. Updating to the protagonist would cause complete disabling of validation of MSON structures in Dredd.
@zdne confirmed the Blueprint team is working on support of JSON schema rendering in the Drafter (not .js) used in the latest protagonist and they are treating it as a priority.
If this is a limitation for using Dredd in your actual project, I would propose some workaround in
beforeAllhooks where you can modify the generated schema in the transaction object under theexpected.body.schemaproperty.obihann commentedon Oct 2, 2015
Hi @netmilk, thank you for your reply. Yes, this may be a limitation, so I will have to look into your suggested work around.
Regarding protagonist, drafter, and drafter.js... Let me see if I fully understand this.
Dredd (latest release) uses Drafter.js (latest release), which uses Protagonist (older 0.x release), which finally uses Dredd (older release again).
The latest version of Protagonist (1.x) uses a newer version of Dredd (not the latest though), however this results in a different feature set than what Dredd.js (using 0.x Protagonist) provides? Because of this my attempts to migrate Dredd to Protagonist 1.x and eliminate Drafter.js is actually a very large task that will not solve my original issues.
Adding all that together, I am seeing that the latest version of Drafter does have the features I need, and the scheduled 1.1.0 release of Drafter will also include 'nullable'. So this is a rough outline of what has to happen before Dredd can properly support
nullableDoes all that sound about right? Sorry, if I am way off.
If I am actually correct, then I think I need to work with @zdne currently to get the 1.1.0 release of Drafter taken care of, and then Protagonist updated to use that. Then I can return to Dredd.
pksunkara commentedon Oct 5, 2015
I think this is more of a correct outline.
obihann commentedon Oct 5, 2015
@pksunkara thanks. What is involved in #1 and how can I assist?
justinabrahms commentedon Nov 6, 2015
I'm having some difficulty with the workaround. Can someone validate that this is roughly what you guys were expecting?
It still fails with the error
fail: body: At '/price_per_seat_cents' Invalid type: null (expected number). I'm using dredd @ 1.0.1. I've also tried makingexpected.bodySchema.price_per_seate_cents.type = 'number,nullable'and it didn't seem to work.You can find the offending code at https://github.com/mitodl/ccxcon/tree/project-skeleton The relevant files are
apiary.apibandapiary_hooks.pyin the root of the repository. Full failure below.26 remaining items
fungjj92 commentedon Feb 10, 2017
Update: Got it to work with:
type: [string, 'null']http://stackoverflow.com/questions/38139657/nullable-fields-in-swagger-on-node-js/38140597#38140597
philsturgeon commentedon Jul 10, 2017
Oh I really really wish this was true, but it isn't.
Unlike @fungjj92 suggested,
type: [string, 'null']is not valid Swagger (even though it is valid JSON Schema).swagger-api/swagger-editor#1302
Open API 3.0 supports
nullable: true, which ReDoc also backported so is what a lot of folks use in v2.0. It's what im using too.Can we get some support for this?
honzajavorek commentedon Jul 11, 2017
@philsturgeon Would you mind to raise the question in https://github.com/apiaryio/fury-adapter-swagger/issues/ ? If it's becoming a de-facto standard even for 2.0, I quite like the idea.
philsturgeon commentedon Jul 11, 2017
I wrote an essay. apiaryio/fury-adapter-swagger#112
jshbrntt commentedon Jan 16, 2018
For those who just want there tests to work when a response returns
nullfor a field just change the type in the specification from.To the following.
Your Dredd tests should now accept
nullfor the field.EDIT: Don't do this although it passes validation its technically not valid and breaks tools like
swagger-codegenThe
x-nullableextension attribute is the way to go, I just need to find I way to make the tests pass in the same way it does when definingtype: ['integer', null].scythargon commentedon Mar 9, 2018
@synthecypher Hi! Have you found it? Regarding
I'm struggling with the same issue currently
InfopactMLoos commentedon Mar 26, 2018
Since the fury-adapter-swagger issue got solved (apiaryio/fury-adapter-swagger#112) when can we expect this to be available in Dredd?
fix(package): Update dredd-transactions to 6.0.2
kylef commentedon Mar 26, 2018
#993 will make this available to Dredd.
InfopactMLoos commentedon May 1, 2018
I must be missing something, I
But I still get an error:
This is my swagger definition for the property:
I thought this would work but did I forget or misunderstood something?
kylef commentedon May 1, 2018
@InfopactMLoos Looks like you're hitting a bug because x-nullable is not being applied recursively (only at root of the schema). I've fixed this in apiaryio/fury-adapter-swagger#172, hopefully we can get this reviewed tomorrow and released into production/Dredd.
InfopactMLoos commentedon May 2, 2018
Ah ok that explains it, thanks for the quick response and work. I will await the fix, let me know if I can be of any help.
kylef commentedon May 3, 2018
@InfopactMLoos Dredd 5.1.7 should include a fix for your problem.