fix: resolveSubtypes() return value is dead code and model.setDiscrim… - #5337
Open
CommanderGeek wants to merge 1 commit into
Open
CommanderGeek wants to merge 1 commit into
CommanderGeek wants to merge 1 commit into
Conversation
…inator(null) is a no-op …or reset (swagger-api#5333) resolveSubtypes() always returned false because its local counter was never incremented, so the caller always ran model.setDiscriminator(null). That call had no effect: the model has no discriminator at that point and the discriminator is set exclusively by resolveDiscriminator() right afterwards. Make resolveSubtypes() void and drop both setDiscriminator(null) branches. No change in generated schemas.
4 of 11 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
…inator(null) is a no-op
…or reset (#5333)
resolveSubtypes() always returned false because its local counter was never incremented, so the caller always ran model.setDiscriminator(null). That call had no effect: the model has no discriminator at that point and the discriminator is set exclusively by resolveDiscriminator() right afterwards.
Make resolveSubtypes() void and drop both setDiscriminator(null) branches. No change in generated schemas.
Pull Request
Thank you for contributing to swagger-core!
Please fill out the following information to help us review your PR efficiently.
Description
ModelResolver.resolveSubtypes(...)always returnedfalsebecause its localcountwas never incremented, so the caller always ranmodel.setDiscriminator(null). That call had no effect: at that point the model has nodiscriminator yet, and the discriminator is set only by
resolveDiscriminator(...), which runs right afterwards.This PR removes the dead code (option 2 from the issue):
resolveSubtypes(...)now returnsvoid; the unusedcountandreturn count != 0are removedmodel.setDiscriminator(null)branches are removedThe call order stays the same and
resolveDiscriminator(...)still runs every time, so the generated schemas don't change.Fixes: #5333
Type of Change
Checklist
Screenshots / Additional Context
No new tests, since generated output is unchanged. The full
mvn installpasses, including all module tests.Companion PR for the other branch: #5338