Skip to content
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

Allow file generation exclusion #32

Open
Nirei opened this issue Nov 11, 2021 · 3 comments
Open

Allow file generation exclusion #32

Nirei opened this issue Nov 11, 2021 · 3 comments

Comments

@Nirei
Copy link

Nirei commented Nov 11, 2021

It would be nice to have some mechanism to exclude certain files from being generated.

For example, a list of files in some kind of .openapi-generator-plus-ignore file. This would come in handy when you only need a part of an implementation or don't want certain files (i.e.: a README or impl file) to regenerate each time the command is run.

@Nirei
Copy link
Author

Nirei commented Nov 11, 2021

I've shuffled over the code for a while now and it would seem that individual file responsibility is delegated to the client generators? So this might be a bit of a fuzz to implement.

Assuming that's correct:

  • Maybe, to do it in a backwards compatible way, it'd be possible to optionally allow generators to access such a list of filenames and let them inhibit themselves.
  • If backwards compatibility is not an issue, it'd might be cleaner to make individual generators send objects describing files back to openapi-generator-plus and let it handle the writing responsibility?

@karlvr
Copy link
Owner

karlvr commented Nov 15, 2021

@Nirei Thanks for your comments and thoughts. Yes, that's right, generators do currently take on the responsibility of writing all of their files. There is a generator-common module that they all use, which includes the emit function... so it would be possible to add support there and then have it adopted in all generators quite easily.

It's interesting to consider whether generators should be responsible for outputting their own files... I think that's still the right approach, as there could be a variety of mechanisms for outputting files.

The .ignore file idea is a good one. If support for it was added to that emit function, I presume it would look like a function that takes an output filename and then it looks in that dir for the ignore file and all parent dirs to then check for a matching pattern, using glob?

Are you keen to try implementing this?

@Nirei
Copy link
Author

Nirei commented Nov 15, 2021

Why, yes! I can sure give it a try 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants