domaindrivendev / Swashbuckle.AspNetCore

Swagger tools for documenting API's built on ASP.NET Core
MIT License
5.21k stars 1.3k forks source link

[Bug]: Swagger produces different swagger file on Linux #2947

Open Chaosflo opened 3 months ago

Chaosflo commented 3 months ago

Describe the bug

We have Verify tests which compares the swagger files and notifies us if something has changed per accident.

Now we have the issue because of the addition of #2899 that this produces different results, locally (Windows) and on our Azure Pipelines (Linux). The comparison fails!

The easiest fix would be to make this optionally configurable and let the user decide. This way I could then fixate the newline characters

Would be a very nice addition. Thank u! Greetings Florian

Expected behavior

Newline Characters are configureable

Actual behavior

Newline Characters are defined by Environment.Newline which differs from the Operating System

Steps to reproduce

No response

Exception(s) (if any)

No response

Swashbuckle.AspNetCore version

6.6.2

.NET Version

net8.0

Anything else?

No response

martincostello commented 3 months ago

Thanks for raising this issue.

Personally I'd push back on this being a bug per-se, as using Environment.NewLine is a common thing to do, but I can see why this would be annoying in your use case.

We can look at seeing if we can make this configurable in future, but for now I would suggest adjusting your verification tests to ignore line endings.

Chaosflo commented 3 months ago

Fine for me ^^

Tip: For anyone stumbling on this, don't forget that you need to replace the string \r\n not the control characters. This way you replace the characters in the json string (in my case) ^^ image

StefanSchoof commented 3 months ago

Sound similar to #2558. I solved this with a .gitattributes and a eol=lf.