Closed Remco75 closed 7 years ago
you can simply do this by doing this check in generators/index.js if (schema.example) { mockStr = schema.example } But it's no use for me until #32 is solved. Now I cloned the repo for the time being and did this fix. If you want to solve #32 I will make a PR
I was using the example
in the early versions, however some swagger specs defined wrong examples and not adhered to the spec when examples were defined. This led to failures of validator tools like is-my-json-valid
.
This is the change - https://github.com/subeeshcbabu/swagmock/commit/2493b9c642baf453ebf8af83e325b03f2eeba770
I can introduce an option useExamples
and based on the that flag, continue to support the schema.example, what say?
If you want to send a PR for this, it would be cool.
ok, I see your point. Personally I think it's the users responsibility to generate proper examples, or the validation of the swagger should take this into account.
But I think the useExamples is a very good idea. I will do a PR tomorrow. If you do a backport to the 0.0x branch (I will continue that discussion in #32 )
And thnx for the swift response!
Sorry, couldnt find the time, will submit pr after the weekend
@subeeshcbabu , created a PR #39 for this on the 0.0.x branch. if you approve I will also create it on the 1.x branch. THnx!
Great. Thx.
When mocks for properties are generated, swagger supports 'examples' to be set. Using this makes for much more sensible mocks.