Skip to content

Conversation

@sobychacko
Copy link
Contributor

Fixes: #1335

#1335

Add support for maintaining JSON property order in generated schemas using @JsonPropertyOrder. Users can now control the order of properties in their JSON schemas by annotating their classes/records with @JsonPropertyOrder.

  • Add JacksonOption.RESPECT_JSONPROPERTY_ORDER to BeanOutputConverter
  • Add test to verify schema property ordering
  • Update documentation with property ordering example

Fixes: spring-projects#1335

spring-projects#1335

Add support for maintaining JSON property order in generated schemas using
@JsonPropertyOrder. Users can now control the order of properties in their
JSON schemas by annotating their classes/records with @JsonPropertyOrder.

- Add JacksonOption.RESPECT_JSONPROPERTY_ORDER to BeanOutputConverter
- Add test to verify schema property ordering
- Update documentation with property ordering example
@ilayaperumalg ilayaperumalg self-assigned this Nov 8, 2024
@ilayaperumalg ilayaperumalg added this to the 1.0.0-M4 milestone Nov 8, 2024
record TestClassWithJsonPropertyOrder(
@JsonProperty("string_property") @JsonPropertyDescription("string_property_description") String someString,

@JsonProperty(required = true, value = "foo_property") String foo,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a validation, we could perhaps change the order here to make sure the actual order from "JsonPropertyOrder" dictates the ordering. will change it when merging.

@ilayaperumalg
Copy link
Member

The changes LGTM. We also can add/update test at the OpenAiChatModelResponseFormatIT as quoted from the issue. Will update this when merging.

@ilayaperumalg
Copy link
Member

Rebased and merged as 79266be along with the tests update c1fc687

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.

BeanOutputConverter.getJsonSchema() should keep the Key ordering of Record

2 participants