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
Split filename-template for both entities and paths #60
Comments
Thanks for raising this @LePips!
Yeah I agree. It's not common to suffix model files with FooModel.swift. It would make much more sense to add the suffix to the paths (i.e GetFooRequest.swift or similar).
Generally this seems like a reasonable idea, but the filename template is also used on some smaller extension files that occasionally get generated too, so not everything falls into the 'paths' or 'entities' bucket. In general, I did want to move the As an alternative workaround, had you considered trying to rename the conflicting operations in the configuration file? Does that work how I'm thinking it would? rename:
operations:
myConflictingOperationName: someOtherName |
I'm all for having everything in the config. I'm also happy to aid in your work if you need any.
We can just apply these names if they apply to an entity or path from the schema, not files with extensions. I will still have to take a deeper look at how file name generation is done.
I'm not knowledgeable of how that flag works specifically, but it does not fix the issue. Even then, it would be problematic to go through every conflict in a large schema like in my case. I'm way too lazy. |
Finally looking at the file generation, might I propose a change to these extension files and general generated directory structure? Both entities and paths sometimes create their necessary helper methods/namespaces/objects and they live within the
This would mean that the two config options (instead of flags) As a reference, this is what the OpenAPI generator does. |
That sounds like a good approach 👍
This is the best approach, it matches the direction we want to go with #74. But don't worry about merging them if
|
Using the below files, everything is freely available:
Command used:
With the
operations
paths style I get conflicting filenames between entities and paths. I actually need to use theoperations
paths style becauserest
results in another error because the spec has a path literally called "Path" and that creates a different issue. You can simply change the paths style and generate to see the error.Anyways, the only way to properly avoid these file conflicts is to use
--entityname-template "$0Model"
which properly renames all entity files and the corresponding entities, however I would not like to have every entity to be that same name due to convenience. I think a flag change for the--filename-template <filename-template>
would be more appropriate to split into two flags:--entity-filename-template <entity-filename-template>
--paths-filename-template <paths-filename-template>
These flags would create a further separation between the two types and aid in these types of conflicts. If this gets greenlit I'll be more than happy to implement to get comfortable with this project.
The text was updated successfully, but these errors were encountered: