5

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.

4

1 回答 1

1

这是因为 Git 的配置。我想这个博客会对你有所帮助。 配置 Git 以处理行尾 - GitHub 帮助

解决方案

git config --global core.autocrlf true
于 2019-12-30T09:01:05.200 回答