-
Notifications
You must be signed in to change notification settings - Fork 6k
Improved ExampleGenerator #4797
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
Conversation
- Now takes into account enum and uri/url formats for strings. - Uses example for referenced objects if available. - Proper examples get generated for specific numeric formats, because more specific formats now get checked before generic format. - Honors min and max values for numerical properties, if set.
| import java.util.Set; | ||
|
|
||
| public class ExampleGenerator { | ||
| private static final Logger log = LoggerFactory.getLogger(ExampleGenerator.class); |
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.
@bartkummel thanks for the PR. Just a minor suggestion. We use logger instead of log in other Java class files. Do you mind using the same (ie. logger) to make it consistent with other files?
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.
Sure! I've renamed log to logger in the latest commit.
|
@bartkummel thanks for the PR. I like the new feature you added: randomized example values (numeric), but this may introduce extra noise during change review. I'll merge this and see if the community also has feedback on this. |
|
The random integers have the effect that now after each generation we get different numbers. Currently those examples seem to be not used in many languages (just NodeJS, as far as I can see), but it is already annoying (e.g. see ccc117c for how a simple nothing-changing update looks). If we need randomness, could we make it deterministic? I.e. start the RNG always with the same seed (per ExampleGenerator instance, e.g.), so same input gets same output? This would turn down the noise. |
* Improved ExampleGenerator: - Now takes into account enum and uri/url formats for strings. - Uses example for referenced objects if available. - Proper examples get generated for specific numeric formats, because more specific formats now get checked before generic format. - Honors min and max values for numerical properties, if set. * Ran script `bin/nodejs-petstore-server.sh`. * Renamed log to logger to conform to coding standard.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)2.3.0branch for breaking (non-backward compatible) changes.See issue #4796
Description of the PR
Improved ExampleGenerator: