diff --git a/src/main/java/run/halo/moments/MomentEndpoint.java b/src/main/java/run/halo/moments/MomentEndpoint.java index 42ae3de..2cc350d 100644 --- a/src/main/java/run/halo/moments/MomentEndpoint.java +++ b/src/main/java/run/halo/moments/MomentEndpoint.java @@ -48,6 +48,7 @@ public RouterFunction endpoint() { .response(responseBuilder() .implementation(ListResult.generateGenericClass(ListedMoment.class)) ); + MomentQuery.buildParameters(builder); }) .GET("moments/{name}", this::getMoment, builder -> builder.operationId("GetMoment") diff --git a/src/main/java/run/halo/moments/MomentQuery.java b/src/main/java/run/halo/moments/MomentQuery.java index fa94bf7..d580437 100644 --- a/src/main/java/run/halo/moments/MomentQuery.java +++ b/src/main/java/run/halo/moments/MomentQuery.java @@ -1,16 +1,20 @@ package run.halo.moments; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; import static run.halo.app.extension.index.query.QueryFactory.all; import static run.halo.app.extension.index.query.QueryFactory.and; import static run.halo.app.extension.index.query.QueryFactory.contains; import static run.halo.app.extension.index.query.QueryFactory.equal; import static run.halo.app.extension.index.query.QueryFactory.greaterThanOrEqual; import static run.halo.app.extension.index.query.QueryFactory.lessThanOrEqual; +import static run.halo.app.extension.router.QueryParamBuildUtil.sortParameter; import static run.halo.app.extension.router.selector.SelectorUtil.labelAndFieldSelectorToListOptions; +import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.media.Schema; import java.time.Instant; import org.apache.commons.lang3.StringUtils; +import org.springdoc.core.fn.builders.operation.Builder; import org.springframework.data.domain.Sort; import org.springframework.lang.Nullable; import org.springframework.util.MultiValueMap; @@ -18,6 +22,7 @@ import run.halo.app.extension.ListOptions; import run.halo.app.extension.PageRequest; import run.halo.app.extension.PageRequestImpl; +import run.halo.app.extension.router.IListRequest; import run.halo.app.extension.router.SortableRequest; import run.halo.app.extension.router.selector.FieldSelector; @@ -141,4 +146,47 @@ private Boolean convertBooleanOrNull(String value) { private Instant convertInstantOrNull(String timeStr) { return StringUtils.isBlank(timeStr) ? null : Instant.parse(timeStr); } + + public static void buildParameters(Builder builder) { + IListRequest.buildParameters(builder); + builder.parameter(sortParameter()) + .parameter(parameterBuilder() + .in(ParameterIn.QUERY) + .name("keyword") + .description("Moments filtered by keyword.") + .implementation(String.class) + .required(false)) + .parameter(parameterBuilder() + .in(ParameterIn.QUERY) + .name("ownerName") + .description("Owner name.") + .implementation(String.class) + .required(false)) + .parameter(parameterBuilder() + .in(ParameterIn.QUERY) + .name("tag") + .description("Moment tag.") + .implementation(String.class) + .required(false)) + .parameter(parameterBuilder() + .in(ParameterIn.QUERY) + .name("visible") + .description("Moment visible.") + .implementation(Moment.MomentVisible.class) + .required(false)) + .parameter(parameterBuilder() + .in(ParameterIn.QUERY) + .name("startDate") + .implementation(Instant.class) + .description("Moment start date.") + .required(false)) + .parameter(parameterBuilder() + .in(ParameterIn.QUERY) + .name("endDate") + .implementation(Instant.class) + .description("Moment end date.") + .required(false)) + ; + } + } diff --git a/src/main/java/run/halo/moments/uc/UcMomentEndpoint.java b/src/main/java/run/halo/moments/uc/UcMomentEndpoint.java index 727d83d..3e7a166 100644 --- a/src/main/java/run/halo/moments/uc/UcMomentEndpoint.java +++ b/src/main/java/run/halo/moments/uc/UcMomentEndpoint.java @@ -58,11 +58,18 @@ public RouterFunction endpoint() { .response(responseBuilder() .implementation(ListResult.generateGenericClass(ListedMoment.class)) ); + MomentQuery.buildParameters(builder); }) .GET("moments/{name}", this::getMyMoment, builder -> builder.operationId("GetMyMoment") .description("Get a My Moment.") .tag(tag) + .parameter(parameterBuilder() + .name("name") + .in(ParameterIn.PATH) + .required(true) + .implementation(String.class) + ) .response(responseBuilder() .implementation(Moment.class)) )