Commit fdfde2a9 authored by cnguyen2's avatar cnguyen2
Browse files

Comma-separated values for query params

parent 23e736e5
Pipeline #167336 passed with stages
in 6 minutes
......@@ -24,7 +24,6 @@ import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.enums.ParameterIn;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.media.ExampleObject;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
......@@ -48,7 +47,7 @@ public class GeneResource {
@GET
@Metered
@Path("/drosophila/genes/{id: FBgn[0-9]{7}}")
@Operation(summary = "Get information for a fly gene.")
@Operation(summary = "Get information for a drosophila gene.")
public DrosophilaGene getFlybaseGene(
@Parameter(
description = "Flybase gene identifier in format FBgn[0-9]{7}.",
......@@ -60,7 +59,7 @@ public class GeneResource {
@GET
@Metered
@Path("/drosophila/genes")
@Operation(summary = "Get information for a list of fly genes")
@Operation(summary = "Get information for a list of drosophila genes")
@APIResponse(
responseCode = "200",
description = "A list of found genes.",
......@@ -73,8 +72,8 @@ public class GeneResource {
public Response getFlybaseGenes(
@Parameter(
in = ParameterIn.QUERY,
description = "Flybase gene identifiers in format FBgn[0-9]{7}")
@QueryParam("ids") Set<String> ids,
description = "Comma-separated list of Drosophila gene identifiers in format FBgn[0-9]{7}")
@QueryParam("ids") String idsStr,
@QueryParam("symbol") String symbol,
......@@ -83,6 +82,7 @@ public class GeneResource {
example = "knirps")
@QueryParam("fullname") String fullname,
@QueryParam("annotationId") String annotationId) {
Set<String> ids = idsStr == null ? Set.of() : Set.of(idsStr.split(","));
long paramCnt = Stream.of(symbol, fullname, annotationId).filter(p -> p != null).count();
if (paramCnt > 0 && ids.size() > 0 || ids.size() == 0 && paramCnt != 1) {
......@@ -126,13 +126,15 @@ public class GeneResource {
@GET
@Metered
@Path("/tribolium/genes")
@Operation(summary = "Get information for a list of fly genes")
@Operation(summary = "Get information for a list of tribolium genes")
public List<TriboliumGene> getTriboliumGenes(
@Parameter(
in = ParameterIn.QUERY,
description = "Tribolium gene identifiers in format TC[0-9]{6}",
examples = @ExampleObject(name = "TC001906", value = "TC001906"))
@QueryParam("ids") Set<String> ids) {
description = "Comma-separated list of Tribolium gene identifiers in format TC[0-9]{6}",
example = "TC001906")
@QueryParam("ids") String idsStr) {
Set<String> ids = idsStr == null ? Set.of() : Set.of(idsStr.split(","));
return ids.stream()
.filter(id -> checkTCID(id))
.map(id -> tGeneRepo.get(id))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment