Skip to content

Consistently use BuilderRefs for collections in builders#2743

Merged
JordonPhillips merged 2 commits into
mainfrom
cors-randomness
Aug 18, 2025
Merged

Consistently use BuilderRefs for collections in builders#2743
JordonPhillips merged 2 commits into
mainfrom
cors-randomness

Conversation

@JordonPhillips
Copy link
Copy Markdown
Contributor

This updates every map, set, or list in a builder to use BuilderRef. BuilderRef exists to minimize the number of copies we have to do as well as to make it harder to forget to make immutable copies of collections.

In a few cases the underlying collection was changed to preserve or enforce order. This fixes #2734 because the source of that issue was not having a consistent order for responseParameters. That's now kept sorted, like basically every other part of the openapi document.

This resulted in fixing a few other unknown bugs. In some instances we had been directly referencing collections from the builder instead of making any kind of copies. There was also at least one test that asserted non-existent behavior that only passed because of the accident of ordering.

Note that mutability was preserved where it existed already. I had initially removed all of that, but there were some areas relying on it (notably openapi plugins).


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This adds static methods to BuilderRef for creating sorted maps
and sets, including an optional custom comparator.
@JordonPhillips JordonPhillips requested a review from a team as a code owner August 15, 2025 14:33
Comment thread smithy-jsonschema/src/main/java/software/amazon/smithy/jsonschema/Schema.java Outdated
This updates every map, set, or list in a builder to use BuilderRef.
BuilderRef exists to minimize the number of copies we have to do
as well as to make it harder to forget to make immutable copies of
collections.

In a few cases the underlying collection was changed to preserve
or enforce order.
@JordonPhillips JordonPhillips merged commit 5df575d into main Aug 18, 2025
9 checks passed
@JordonPhillips JordonPhillips deleted the cors-randomness branch August 18, 2025 15:15
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.

@cors trait causes non-deterministic OpenAPI output key ordering

2 participants