-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
JSON/XML/CSV nil options #231
Conversation
I think this looks great! nice job! The only think i question is setting firstname or autoincrement on the Field. I almost think that one should be required. Let me know your thoughts. |
I chose for |
Let me test this one out a little bit. Cause i like the idea of not needing to pass in options to json and xml and having it automatically generate some for you. But I would like that generation to be a little bit more full of what feels like visually appealing data. you know what i mean? |
Ah, now I see what you mean. For my use case, as long as the data is valid
I was happy.
I'll think if there is something easy that can be done 🤔
…On Mon, Mar 27, 2023 at 10:38 PM Brian Voelker ***@***.***> wrote:
Let me test this one out a little bit. Cause i like the idea of not
needing to pass in options to json and xml and having it automatically
generate some for you. But I would like that generation to be a little bit
more full of what feels like visually appealing data. you know what i mean?
—
Reply to this email directly, view it on GitHub
<#231 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABI5JACXXNBQBCPSA7LXULW6H3FPANCNFSM6AAAAAAWJO6XKI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Ya from a programmers perspective I agree. as long as my code sees it as good then im good. But I do have a decent amount of people that use it for visuals. Things like front end. I am also building gofakeit.com and would like it if this feature had more visually appealing outputs as well. |
Would an output like this be "visual" enough?
or do you want to go all the way to named properties like:
|
ya that looks good. I would think randomly between 2 and 8 fields and maybe picking between the top 8 most used functions. |
Implement random Fields from existing Lookups
I tried something different. It now picks a random number of existing parameterless FuncLookup and uses that to generate data. An example looks like this:
or
|
I think this looks great! The only thing i would like to figure out is being able to get random lookup functions to run without needing to add internalFuncLookups. The lookup funcs are used in cmd, server and gofakeit.com. So adding to it would have it show up on the list of available functions to run. |
I'm not sure I'm following. In particular I'm confused about the interest/value of having this particular function show up on the list of available functions to run from cmd, server and gofakeit.com. The lookup function I added 'internal_ExampleFields' is returning a That is the reason why I added the The reason to return a To sum up my understanding, and I may be missing something obvious, I see three ways of faking that value:
What am I missing? 🤔 I hope I'm not being too obnoxious. I really appreciate you engaging and the project you've built! 😄 |
I think your right. I read the code too quickly. Its not adding to the lookup map its just able to retrieve by the get lookup func. I think you understand my perspective pretty well so ill get this merged in. Before I do can you update the README.md as well. people use that as reference and I think by adding a little comment near the json,xml and csv sections saying something like "you can pass nil and it will auto generate for you" would help finish it off. I will wait to do a release once we hash out your other pr |
Merged! Thanks for your contributions. I think people will enjoy the addition. |
This PR enables the generation of JSON and XML when the corresponding option objects are nil.
This is useful when one doesn't care about the structure of the generated JSON/XML as long as it is valid.
Some of the tests check for a well formed
JSONOptions
and fail when it is missing required parameters (eg.Fields
orRowCount
). While it may seem that a nilJSONOptions
would be equally malformed, one can argue that when the options are nil it means that they are not specified instead of misspecified.In that case, we can leverage the gofakeit mechanics to generate a random
JSONOptions
/XMLOptions
, and proceed with the generation as usual.Tests pass and code coverage is unchanged.