Skip to content

fix: resolveSubtypes() return value is dead code and model.setDiscrim… - #5337

Open
CommanderGeek wants to merge 1 commit into
swagger-api:3.0.0from
CommanderGeek:fix/5333-remove-dead-resolveSubtypes-return
Open

CommanderGeek wants to merge 1 commit into
swagger-api:3.0.0from
CommanderGeek:fix/5333-remove-dead-resolveSubtypes-return

Conversation

@CommanderGeek

@CommanderGeek CommanderGeek commented Sep 30, 2026 •

Copy link
Copy Markdown

…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 returned false because its local count was never incremented, so the caller always ran model.setDiscriminator(null). That call had no effect: at that point the model has no
discriminator 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 returns void; the unused count and return count != 0 are removed
  • the no-op model.setDiscriminator(null) branches are removed
  • a short comment explains why no discriminator reset is needed

The call order stays the same and resolveDiscriminator(...) still runs every time, so the generated schemas don't change.

Fixes: #5333

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

  • I have added/updated tests as needed
  • I have added/updated documentation where applicable
  • The PR title is descriptive
  • The code builds and passes tests locally
  • I have linked related issues (if any)

Screenshots / Additional Context

No new tests, since generated output is unchanged. The full mvn install passes, including all module tests.
Companion PR for the other branch: #5338

…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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant