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

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

Closed
Chaosflo opened this issue Jun 12, 2024 · 5 comments · Fixed by #3255
Closed

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

Chaosflo opened this issue Jun 12, 2024 · 5 comments · Fixed by #3255
Labels
Milestone

Comments

@Chaosflo
Copy link

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

@Chaosflo Chaosflo added the bug label Jun 12, 2024
@martincostello
Copy link
Collaborator

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
Copy link
Author

Chaosflo commented Jun 13, 2024

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

@martincostello martincostello added the help-wanted A change up for grabs for contributions from the community label Jun 13, 2024
@StefanSchoof
Copy link

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

@RainDance74
Copy link
Contributor

RainDance74 commented Feb 7, 2025

Would it be ok if I open a PR in which I replace Environment.NewLine with \r\n (Windows EOL), or should I find the way to make it's optional?
Seems to me that the problem is important and I have encountered the same thing as the author of this Issue.

@martincostello
Copy link
Collaborator

Configurable would be the preference.

@martincostello martincostello added this to the v7.3.0 milestone Feb 12, 2025
@martincostello martincostello removed the help-wanted A change up for grabs for contributions from the community label Feb 12, 2025
martincostello pushed a commit that referenced this issue Feb 12, 2025
Add support for configuring the new line string to use for XML comments in the OpenAPI document.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants