Refactor filter descriptor type checks in SwaggerGen#3125
Merged
martincostello merged 5 commits intoNov 4, 2024
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Given that the public API allows to register a filter in this form without any specific validation on not assigning the Type property:
in which case, opening the swagger UI returns a
NullReferenceException(in developer error page) with no reference to user source code.Looking into the library source code, I found out that the "proper" way to do the registration is:
but I just felt that the first option should also be available with minimal behavior changes, given that it is a possible choice in the public API.
The issue or feature being addressed
Details on the issue fix or feature implementation
I added an alternative validation on the filter type for when the
FilterInstanceis set but not theTypeof theFilterDescriptor.