-
Notifications
You must be signed in to change notification settings - Fork 18
More robust identifier parsing? #9
Comments
This seems fine to me The question I have is: are all of these symbols and non-unicode characters allowed in OAS (where they would be used as names)? Is having a parameter with
Symbols & non-unicode characters aside, I believe staying as close as possible to the original naming in the document is important. I'd argue that if the user wants to change the name of the variable in the resulting generated code, they should probably change the name of the original source (parameter, enum, whatever it is). That said, the generator should be doing this, staying as close as possible to the original naming. Is that fair? Generally, I would like to see use-cases for the above. Personally, I'm ok with saying that if one has |
Totally understand, my perspective has been from the stand point of a user that doesn't have control of the underlying API, so I was thinking this should handle potentially misbehaving API docs, etc. However, thinking about gnostic+plugin as being more of a true-to-OAS conversion (which would be way more maintainable), any customization a user would want could be implemented with a little JSON preprocessing (via JSON patch, etc), especially if they want to change the resulting method names, etc.
Resetting my perspective a little, I'm curious though: with gnostic + plugins, we have 2 passes, the process to create the surface model, then the plugin process to turn the model into Go: wouldn't it be better to have the first pass creating the model perform any OAS compliance checks/processing, and limit the go plugin to make sure it's output is syntactically viable go? From what I can find, OAS limits some keys/names to ASCII alphanumeric ( and Ultimately though, our discovery docs should be OAS compliant (maybe I/we can influence that), and preprocessing can fix any of this... so while it might seem like I ranted, I don't actually feel strongly either way, I just enjoy the discussion and figuring out the scope of this project, and I'm 100% on board with whatever's decided. :) |
This is valuable! Insight we don't necessarily (definitely don't) have.
Yes, this world is much more well-defined and less chaotic (albeit OAS is a large, sometimes chaotic format)
Yes! This would be the best place for any linting we want to do. This might be a more involved discussion in a separate issue on
Yes definitely. The Go plugin shouldn't be concerned with what is "valid OAS" but expect that what it is given is valid. Then, it can massage things into the Go-specific conventions as needed. This should be done regardless of the previous point about validating OAS in
sgtm
Yep, lets discuss this in an issue on |
This would fix #8 #6 in a more robust way
n
'_
' or an empty string.If they're done in that order and if non-unicode letters are replaced with an empty string, it would handle fields that start with non-unicode letters and numbers. Like this:
https://play.golang.org/p/yyG0XUihd59
IMO it'd be great if we could let the user decide what they want replaced by using something like https://github.com/spf13/viper. It would allow them to use flags for most options, but could allow further customization if the user needs something more elaborate (i.e. replacing entire field names in case they don't like
myType
, etc). This would minimize hand-tweaking of the resulting code.Thoughts? I can put a PR in unless you'd rather not have a dependency like spf13/viper.
The text was updated successfully, but these errors were encountered: