1

We're using Swagger Codegen 2.4.5 to generate models from our API. Everything is working exactly as we need with one relatively minor exception.

We're generating C# models, and as per windows these are typically stored with CRLF line endings. Whenever we run the generator these files are generated with the LF line endings.

We'd like all the models to be generated with CRLF instead of LF. Is there a way to modify this behaviour?

I've looked into how mustache is used - a bit - and read through the general command line options for codegen and the csharp specific options (java -jar swagger-codegen-cli-2.4.5.jar config-help -l csharp), and couldn't find anything.

For further clarification:

Currently this is a problem as each time you checkout then run generation again, then models appear as changed. This is simply because they're now encoded with LF line-endings, whereas git has checked them out as CRLF (which we cannot change)

The only other option I can think of at the moment, is to rewrite each file in the project with CRLF after the generation process has completed. I'd prefer it if there was a way via the generator tho.

Simon Laing
  • 1,134
  • 5
  • 16

1 Answers1

1

this is because of the config by Git. I think this blog will help you. Configuring Git to handle line endings - GitHub Help

solution

git config --global core.autocrlf true
Frank
  • 11
  • 2
  • 1
    My git config is already set to `autocrlf`, this affects the way line endings are committed. But doesn't affect the defection of changes locally. If a file is changed to have LF line endings from CRLF (as is happening here) git detects a change, even though the content hasn't (really) changed. – Simon Laing Dec 31 '19 at 13:28