Dredd: Provide example values in Swagger using a vendor specific property (x-example)

Created on 17 Jul 2016  路  9Comments  路  Source: apiaryio/dredd

Hi,

Is it possible to provide example values for uri and query request parameters using a vendor specific property (prefixed with x-*) ?

enum is already used by Swagger UI and Swagger Editor ; It generate a dropdown list with specified values. So, it's impossible to test the API against user defined values.

OpenAPI 2 behavior change

Most helpful comment

Since I really need it, yes of course ;) I'll be able to have a look this weekend. I'm not very found of coffeescript, but I can manage ;)

edit: oh it's plain JS, hooray

All 9 comments

Hey @guillemcanal! Thank you for your thoughts! lThis is exactly what we plan to do. We're going to add x-example to the parameter object very soon. We also want to do a fallback to the default if no example is given (#555).

Very nice! Can't wait! By the way @netmilk, which part of the dredd code is taking care of gathering example values (for swagger files) ? I just can't figure it out. Many thanks to you ;)

@guillemcanal I think these changes would be outside of Dredd itself and actually in the Swagger adapter we use for converting Swagger to the API Elements format that Dredd internally consumes.

The change should be as simple as adding the sample to the structure for Href within https://github.com/apiaryio/fury-adapter-swagger/blob/master/src/parser.js#L1182. It should just add the sample to the "value" part (example of an API Elements document with a Href sample: https://github.com/apiaryio/drafter/blob/master/test/fixtures/api/action-parameters.json#L55)

@guillemcanal Would you be willing to work on this? I can provide you with pointers and any support you may need during implementation 馃敤

Since I really need it, yes of course ;) I'll be able to have a look this weekend. I'm not very found of coffeescript, but I can manage ;)

edit: oh it's plain JS, hooray

@guillemcanal Great, thanks! I'm already working on https://github.com/apiaryio/dredd/issues/555 which should provide workaround. And yes, we're trying to write new stuff in plain JS as it started evolve :)

@guillemcanal Any chance you had time to look into it?

Not yet, I'll try to work on it this week.

@guillemcanal Just in case you get back to this, I took care of it. It should bubble up the dependency chain and be published as part of Dredd soon. It turned out to be a bit more tricky after all :)

Was this page helpful?
0 / 5 - 0 ratings