Skip to content

Conversation

Fr4nk03
Copy link
Contributor

@Fr4nk03 Fr4nk03 commented Oct 9, 2025

Description

This pull request resolves a non-deterministic behavior in the core serialization test suite, ensuring CI stability.

Problem: The test io.swagger.v3.core.serialization.properties.PropertySerializationTest can fail intermittently because the default Jackson ObjectMapper does not guarantee the serialization order of an object's properties. It uses Java Reflection to discover class fields, and the order in which the JVM returns these fields is not specified and can vary between runs or Java versions. This non-deterministic behavior was detected using the NonDex tool. This pull request is for a simple fix to make the test deterministic.

Reference: https://tedblob.com/jackson-serialization-order/

Fixes: The existing tests used a direct assertEquals on the serialized string. This PR introduces a new test utility, JsonAssert, with a static method assertJsonEquals. This method provides a robust, order-insensitive comparison of two JSON strings by:

  1. Parsing both strings into a JsonNode tree structure.
  2. Using JsonNode.equals(), which performs a deep, semantic comparison.

Note: Only PropertySerializationTest has been refactored to use this new assertion, making them stable and reliable while still correctly verifying the serialized output. Other tests under io.swagger.v3.core.serialization have NOT yet been refactored. They can be refactored after this PR gets reviewed and accepted.

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)

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.

2 participants