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

Initialize Urls property with an empty collection #3135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

averichev
Copy link

@averichev averichev commented Nov 8, 2024

Updated the Urls property in ConfigObject to initialize with Enumerable.Empty<UrlDescriptor>() instead of null. This change ensures the property is always a valid collection, eliminating the need for null checks and preventing potential null reference exceptions when accessing or iterating over the property. Improves code safety and aligns with best practices for handling collections.

…t null values

Updated the `Urls` property in `ConfigObject` to initialize with `Enumerable.Empty<UrlDescriptor>()` instead of `null`. This change ensures the property is always a valid collection, eliminating the need for null checks and preventing potential null reference exceptions when accessing or iterating over the property. Improves code safety and aligns with best practices for handling collections.
@averichev averichev changed the title refactor: initialize Urls property with an empty collection to preven… Initialize Urls property with an empty collection Nov 8, 2024
@martincostello
Copy link
Collaborator

I don't have a problem with this unless Swagger UI treats empty and null/undefined differently.

This change ensures the property is always a valid collection

With the qualifier "by default" - there's nothing to stop it being null.

Copy link
Contributor

github-actions bot commented Jan 8, 2025

This pull request is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further changes are made.

@github-actions github-actions bot added the stale Stale issues or pull requests label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issues or pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants