Open zudov opened 7 years ago
Good point.
More than kebab case, I would say that we should put asserts that check that values are contained in the possible enum values when provided.
When writing that example with the case
I was on the fence regarding what should be the default case: argument as it is or throw (InvalidArgumentException. ...)
, like:
:projection
(case (name projection)
"no-acl" "noAcl"
"noAcl" "noAcl"
"full" "full"
(throw (InvalidArgumentException. (str "Unexpected value for 'projection' argument: " projection))))
If we are sure that there won't be need to specify anything that's not in the API model, throwing (or checking it via :pre
, would of course be better.
I would go with generating an assert
or a :pre
, they throw if the things don't look right.
About kebab casing: not sure if we need to do it, as long as we document what goes into the enum in the docstring. But if we want to provide the kebab casing, then we might as well go all the way to use keywords instead of strings.
to use keywords instead of strings
This is why I use name
there. Would work on strings, symbols, keywords
and anything nameable.
On Wed, Oct 4, 2017, at 12:00, Fabrizio Ferrai wrote:
I would go with generating an assert or a :pre, they throw if the things don't look right.> About kebab casing: not sure if we need to do it, as long as we document what goes into the enum in the docstring.> But if we want to provide the kebab casing, then we might as well go all the way to use keywords instead of strings.> — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub[1], or mute the thread[2].>
Links:
@zudov TIL you shouldn't answer GH emails in top-posting :D
But I didn't notice the name
there, good point 👍
For parameter like:
We could spew out the code like:
to allow kebab case.
10 (spec-checking) and #19 (docstring generation) would benefit from recognizing them too.