Skip to content

Commit

Permalink
feat(webserver): OpenAPI spec improvement
Browse files Browse the repository at this point in the history
Previously, PagedResult contains ArrayListTotal which is a list with a total in it. But due to that, ArrayListTotal is not recognized as an array for the OpenAPI spec so all the endpoints that use it generates incorrect specification.
Switching to a list fixes the issue.
The serialized form is not impacted.
  • Loading branch information
loicmathieu committed Dec 31, 2024
1 parent c6a09cd commit 6db49ae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

import jakarta.validation.constraints.NotNull;

import java.util.List;

@Getter
@NoArgsConstructor
public class PagedResults<T> {
@NotNull
private ArrayListTotal<T> results;
private List<T> results;

@JsonInclude
@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void blueprints(WireMockRuntimeInfo wmRuntimeInfo) {
);

assertThat(blueprintsWithTotal.getTotal(), is(2L));
ArrayListTotal<BlueprintController.BlueprintItem> blueprints = blueprintsWithTotal.getResults();
List<BlueprintController.BlueprintItem> blueprints = blueprintsWithTotal.getResults();
assertThat(blueprints.size(), is(2));
assertThat(blueprints.getFirst().getId(), is("1"));
assertThat(blueprints.getFirst().getTitle(), is("GCS Trigger"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void list() {
assertThat(list.getTotal(), is(6L));
assertThat(list.getResults().size(), is(6));
assertThat(list.getResults(), everyItem(hasProperty("disabled", is(true))));
assertThat(list.getResults().map(NamespaceWithDisabled::getId), containsInAnyOrder(
assertThat(list.getResults().stream().map(NamespaceWithDisabled::getId).toList(), containsInAnyOrder(
"my", "my.ns", "my.ns.flow",
"another", "another.ns", "system"
));
Expand Down

0 comments on commit 6db49ae

Please sign in to comment.