-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
typescript-angular: Feature/model suffix #418
Conversation
…uffixes of generated class and file names
…viceSuffix and serviceFileSuffix parameters
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.
How does this handle invalid suffixes? Do we want to ignore this case? (e.g. modelSuffix could make the model class name invalid by using invalid characters)
Looks good otherwise.
Yes, you are right. You could set the suffix to something invalid. I think this could also be a problem with the filename. From what I see we have following options:
I would say because of the filename probably approach 1 or 2 should be used. Better to catch this problem than to let it fail uncontrolled. Do you know of any similar cases in this project and how it is handled there? |
I added validation for class and file suffixes. As my earlier change with the service suffix has the same problem, I also added the validation for those configurations. Currently I only allow alpha numeric characters for class suffixes. For file suffixes I additionally allow the characters '.' and '-'. If any of the four config values is invalid I throw an IllegalArgument exception and display a message. |
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.
apart from some small documentation improvements this looks good.
} | ||
|
||
private void validateFileSuffixArgument(String argument, String value) { |
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.
please add a method description. describe what argument
and value
are or rename them to better understand their meaning
} | ||
} | ||
|
||
private void validateClassSuffixArgument(String argument, String value) { |
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.
same here
Agreed. Thanks for the PR! |
@wing328 could you please add this to the |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,3.1.x
,4.0.x
. Default:master
.Description of the PR
I introduced a
modelSuffix
andmodelFileSuffix
parameter in order to add suffixes to the generated models and model file names. Taking the samples from the sample, with this setting you could for example change the modelPet
in the filepet.ts
toPetVm
in the filepet.vm.ts
by defining the model suffixVm
and the model file suffix.vm
.The motivation behind this change is to have a clear distincation between generated models and models that are created by a developer. Having the ability to add a suffix to the generated models makes it immediatly obvious of what kind a model is.
I currently see one issue and that is that the class suffix gets also appended to enumeration types. The
StatusEnum
in thePet
class will becomeStatusVmEnum
if I set themodelSuffix
option toVm
. I will have a look if I find how I can avoid that.@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny