Open deniszholob opened 2 years ago
Top-level enums are handled as models. You can set custom prefix / suffix for models or services in the configuration file.
You cannot set them via a regex rule or something like that though right?
SAs an example, say if its a pets-store-results.ts
=> pets-store-results.model.ts
and if its pets-store-types.ts
=> pets-store-types.enum.ts
or by default set it to *.models
and *.enum
if it ends with *-types.ts
in other words, regex *-types.ts
replace with *types.enum.ts
No. Also, take into account that it's not just renaming a file. The class name is renamed accordingly too, and it affects all imports and references from other models and services.
I wasnt really trying to rename the classes, shouldnt be affected by the filename right, i would have assumed both are driven by the api.yml itself? I was more thinking as its generating the filenames/imports it would just rename/update the path as defined in the regex config thats all. Maybe im not realizing the complexity as im not sure about the internal workings.
"The Angular way" states that class HelloIamAClass
should be placed in the file named hello-i-am-a-class.ts
.
So, renaming just the file name would break this.
Also the file name is explicitly referenced when others import the class (other models or services).
Also, trust me, configuring the generator by "just adding a random regex here or there" is not simple at all.
Makes sense, ive tried to use the prefix config with "modelSuffix":".model"
and it took my .
and replaced that with a -
yielding in a -model
suffix :(
I get you are trying to stick to the angular convention but it also has the .services
, .pipes
etc... suffixes which is what i am trying to do with the models.
Not a huge deal in the long run, but a nice to have.
Actually, the model suffix is for the class name.
The file name will be derived from it.
So, if you have "modelSuffix": "Model"
, your model User
will be renamed to UserModel
, and the corresponding file will be user-model.ts
.
Ohhh, so we misunderstood one another, so then my original question is then valid still. Attaching suffixes to file only, not the model name itself.
Does the tool support adding custom suffixes like attaching a
.model.ts
or.enum.ts
to the end of every interface/enum generated? If not, can this be added in?