-
Notifications
You must be signed in to change notification settings - Fork 17
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
Use all property examples in generated mock responses #124
Conversation
6d7ed7f
to
dc29732
Compare
78fe3a4
to
9368846
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be a configurable switch, I am OK with the default being set to off, but there needs to be a way to turn it on via the configuration.
I agree that this makes sense. I suggest using the Go variadic Option pattern for configuring the mock engine on initialisation. This allows us to add optional configuration without breaking the Thank you for your input and guidance! If you have other ideas or suggestions, I'd love to hear them too. |
As long as the ability to 'enable all mock fields' when in mock mode exists as part of the wiretap config (https://pb33f.io/wiretap/configuring/) then the first option sounds OK to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for your contribution!
Currently when the response mock engine generates a response using the
MockGenerator
, the generated responses contain only examples for individual properties that are marked as required, see tests for more details.The reason why generated responses contain only examples for required properties is a side-effect of using mock generator for validation. While it makes sense for validating required fields for requests, it shouldn't affect the response generation.
Changes:
enable-all-mock-response-fields
, to allow only the use of required field examples in the generated mock responses when set tofalse
.This fix uses pb33f/libopenapi#295