GH-5797: Add RESPECT_JSONPROPERTY_ORDER to JsonSchemaGenerator
Thank you for taking time to contribute this pull request!
Problem
BeanOutputConverter configures its JacksonSchemaModule with both JacksonOption.RESPECT_JSONPROPERTY_REQUIRED and JacksonOption.RESPECT_JSONPROPERTY_ORDER, but JsonSchemaGenerator only includes RESPECT_JSONPROPERTY_REQUIRED.
This inconsistency means @JsonPropertyOrder annotations are silently ignored when generating schemas through JsonSchemaGenerator (e.g. via ResponseFormat.jsonSchema(MyClass.class)), even though they work correctly via BeanOutputConverter.
Solution
Add the missing JacksonOption.RESPECT_JSONPROPERTY_ORDER option to the JacksonSchemaModule configuration in JsonSchemaGenerator, aligning it with BeanOutputConverter.
Changes
JsonSchemaGenerator.java— addedJacksonOption.RESPECT_JSONPROPERTY_ORDERtoJacksonSchemaModuleconstructorJsonSchemaGeneratorTests.java— addedgenerateSchemaForTypeRespectsJsonPropertyOrdertest using an@JsonPropertyOrder-annotated class; verified the schema properties are emitted in the declared order
Checklist
- [x] Added
Signed-off-byline to commit (DCO) - [x] Rebased on latest
main - [x] Unit tests added
- [x] Build passes (
mvn package -pl spring-ai-model)
Fixes #5797
LGTM. Adds JacksonOption.RESPECT_JSONPROPERTY_ORDER to JacksonSchemaModule — focused and correct. Test verifies the ordering matches the annotation. Ship it.