Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore – Add OpenAPI documentation #215

Draft
wants to merge 24 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d2b25ce
Bump atlas-web-core to latest upstream version and change imports to …
alfonsomunozpomer Nov 15, 2021
749d747
Add a Spring Boot subproject that includes :app to automate generatio…
alfonsomunozpomer Nov 15, 2021
6fdf19c
Add swagger-core annotations to produce rich documentation from our s…
alfonsomunozpomer Nov 15, 2021
d37ea5d
Add Docker Compose file to start documentation server at localhost://…
alfonsomunozpomer Nov 15, 2021
d9c48bb
Add Docker Compose file to launch Swagger UI
alfonsomunozpomer Nov 15, 2021
d16b466
Fix port of API docs
alfonsomunozpomer Nov 15, 2021
73fd77b
Add README file with instructions on how to run/configure the new sub…
alfonsomunozpomer Nov 15, 2021
96f319e
Decouple experiment and bioentity properties locations
alfonsomunozpomer Nov 16, 2021
b897c3a
Bump atlas-web-core submodule
alfonsomunozpomer Nov 17, 2021
12dd950
Replace my home user dir locations with environment variables
alfonsomunozpomer Nov 18, 2021
bd143f8
Add a Spring Boot subproject that includes :app to automate generatio…
alfonsomunozpomer Nov 15, 2021
19b731d
Add swagger-core annotations to produce rich documentation from our s…
alfonsomunozpomer Nov 15, 2021
519325c
Add Docker Compose file to start documentation server at localhost://…
alfonsomunozpomer Nov 15, 2021
d6567ca
Add Docker Compose file to launch Swagger UI
alfonsomunozpomer Nov 15, 2021
1c8365a
Fix port of API docs
alfonsomunozpomer Nov 15, 2021
dacbe8f
Add README file with instructions on how to run/configure the new sub…
alfonsomunozpomer Nov 15, 2021
cf4213b
Bump atlas-web-core submodule
alfonsomunozpomer Nov 17, 2021
f3b22a7
Replace my home user dir locations with environment variables
alfonsomunozpomer Nov 18, 2021
9cc70bd
Delete docker related config from this earlier version of scxa
ke4 Oct 6, 2023
ba8780a
Merge branch 'chore/openapi-documentation' of https://github.com/ebi-…
ke4 Oct 6, 2023
27ae623
Remove unneeded docker config for openapi
ke4 Oct 6, 2023
879ace2
Merge branch 'develop' of https://github.com/ebi-gene-expression-grou…
ke4 Apr 25, 2024
924fec8
Update atlas-web-core to the latest version
ke4 Apr 25, 2024
10764d0
Implement getExperimentType method also for ScxaExperimentRepository
ke4 Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package uk.ac.ebi.atlas.experimentpage.cellplot;

import com.google.common.collect.ImmutableMap;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand Down Expand Up @@ -60,6 +65,51 @@ else if (!parameterisations.contains(requestParams.get(requiredParameter))) {

@GetMapping(value = "/clusters/k/{k}",
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Operation(
operationId = "clustersCellPlot",
description = "Retrieve cells from a dataset as a 2D projection bucketed by clusters as predicted by " +
"[Scanpy](https://scanpy.readthedocs.io); each point represents a cell in the experiment. Data " +
"are returned in the [Highcharts scatter plot format]" +
"(https://api.highcharts.com/highcharts/series.scatter.data). Each series represents a " +
"different cluster value. There will be as many clusters/series as `k` (see below).",
parameters = {
@Parameter(
name = "experimentAccession",
in = ParameterIn.PATH,
description = "experiment accession of dataset",
example = "E-MTAB-5061"),
@Parameter(
name = "k",
in = ParameterIn.PATH,
description = "number of clusters in which the cells should be split",
schema = @Schema(
type = "integer",
example = "9"
)),
@Parameter(
name = "plotMethod",
in = ParameterIn.QUERY,
description = "2D projection method",
schema = @Schema(
defaultValue = "umap",
allowableValues = {"umap", "tsne"})),
@Parameter(
name = "n_neighbors",
in = ParameterIn.QUERY,
description = "number of neighbours for the UMAP projection (ignored in t-SNE plots)",
required = true,
schema = @Schema(
type = "integer",
example = "20")),
@Parameter(
name = "perplexity",
in = ParameterIn.QUERY,
description = "perplexity value for the t-SNE projection (ignored in UMAP plots)",
required = true,
schema = @Schema(
type = "integer",
example = "35"))
})
public String clusterPlotK(@PathVariable String experimentAccession,
@PathVariable int k,
@RequestParam String plotMethod,
Expand All @@ -74,6 +124,47 @@ public String clusterPlotK(@PathVariable String experimentAccession,

@GetMapping(value = "/clusters/metadata/{metadata}",
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Operation(
operationId = "metadataCellPlot",
description = "Retrieve cells from a dataset as a 2D projection bucketed by a metadata field; each " +
"point represents a cell in the experiment. Data are returned in the [Highcharts scatter plot " +
"format](https://api.highcharts.com/highcharts/series.scatter.data). Each series represents a " +
"value of the cell plots that share it for the specifed metadata field.",
parameters = {
@Parameter(
name = "experimentAccession",
in = ParameterIn.PATH,
description = "experiment accession of dataset",
example = "E-MTAB-5061"),
@Parameter(
name = "metadata",
in = ParameterIn.PATH,
description = "metadata field name over which cells should be bucketed",
example = "inferred cell type - ontology labels"),
@Parameter(
name = "plotMethod",
in = ParameterIn.QUERY,
description = "2D projection method",
schema = @Schema(
defaultValue = "umap",
allowableValues = {"umap", "tsne" })),
@Parameter(
name = "n_neighbors",
in = ParameterIn.QUERY,
description = "number of neighbours for the UMAP projection (ignored in t-SNE plots)",
required = true,
schema = @Schema(
type = "integer",
example = "20")),
@Parameter(
name = "perplexity",
in = ParameterIn.QUERY,
description = "perplexity value for the t-SNE projection (ignored in UMAP plots)",
required = true,
schema = @Schema(
type = "integer",
example = "35"))
})
public String clusterPlotMetadata(@PathVariable String experimentAccession,
@PathVariable String metadata,
@RequestParam String plotMethod,
Expand All @@ -86,6 +177,7 @@ public String clusterPlotMetadata(@PathVariable String experimentAccession,
requestParams.getOrDefault("accessKey", ""));
}

@Hidden
@GetMapping(value = "/expression",
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public String expressionPlot(@PathVariable String experimentAccession,
Expand All @@ -103,6 +195,48 @@ public String expressionPlot(@PathVariable String experimentAccession,
// See also JsonBioentityInformationController.java
@GetMapping(value = "/expression/{geneId:.+}",
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Operation(
operationId = "expressionCellPlot",
description = "Retrieve expression of a specified gene ID from a dataset as a 2D projection; each " +
"point represents a cell in the experiment. The data is returned in the [Highcharts scatter " +
"plot](https://api.highcharts.com/highcharts/series.scatter.data) format in a single series.",
parameters = {
@Parameter(
name = "experimentAccession",
in = ParameterIn.PATH,
description = "experiment accession of dataset",
example = "E-MTAB-5061"),
@Parameter(
name = "geneId",
in = ParameterIn.PATH,
description = "[Ensembl](https://www.ensembl.org) gene ID to show expression of (may " +
"be empty, in which case plot will show no expression in all cells)",
example = "ENSG00000125798"),
@Parameter(
name = "plotMethod",
in = ParameterIn.QUERY,
description = "2D projection method",
schema = @Schema(
type = "string",
defaultValue = "umap",
allowableValues = {"umap", "tsne"})),
@Parameter(
name = "n_neighbors",
in = ParameterIn.QUERY,
description = "number of neighbours for the UMAP projection (ignored in t-SNE plots)",
required = true,
schema = @Schema(
type = "integer",
example = "20")),
@Parameter(
name = "perplexity",
in = ParameterIn.QUERY,
description = "perplexity value for the t-SNE projection (ignored in UMAP plots)",
required = true,
schema = @Schema(
type = "integer",
example = "35"))
})
public String expressionPlot(@PathVariable String experimentAccession,
@PathVariable String geneId,
@RequestParam String plotMethod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ public Experiment getExperiment(String experimentAccession) {
idfParser.parse(experimentDto.getExperimentAccession()),
sdrfParser.parseSingleCellTechnologyType(experimentDto.getExperimentAccession()));
}

@Override
public String getExperimentType(String experimentAccession) {
return experimentCrudDao.getExperimentType(experimentAccession);
}

}
4 changes: 0 additions & 4 deletions app/src/main/java/uk/ac/ebi/atlas/trader/package-info.java

This file was deleted.

2 changes: 1 addition & 1 deletion atlas-web-core
Submodule atlas-web-core updated 55 files
+0 −3 build.gradle
+17 −0 src/main/java/uk/ac/ebi/atlas/experimentimport/ExperimentCrudDao.java
+7 −79 src/main/java/uk/ac/ebi/atlas/model/experiment/Experiment.java
+2 −11 src/main/java/uk/ac/ebi/atlas/model/experiment/ExperimentDesign.java
+101 −0 src/main/java/uk/ac/ebi/atlas/model/experiment/ExperimentDesignTable.java
+15 −20 src/main/java/uk/ac/ebi/atlas/model/experiment/ExperimentType.java
+9 −0 src/main/java/uk/ac/ebi/atlas/model/experiment/baseline/BaselineExperiment.java
+0 −7 src/main/java/uk/ac/ebi/atlas/model/experiment/differential/microarray/MicroarrayExperiment.java
+0 −6 src/main/java/uk/ac/ebi/atlas/model/experiment/sdrf/SampleCharacteristics.java
+6 −7 src/main/java/uk/ac/ebi/atlas/model/experiment/summary/AssayGroupSummaryBuilder.java
+13 −19 src/main/java/uk/ac/ebi/atlas/model/experiment/summary/ContrastSummaryBuilder.java
+1 −1 src/main/java/uk/ac/ebi/atlas/model/resource/XmlFile.java
+11 −0 src/main/java/uk/ac/ebi/atlas/model/resource/XmlFileConfigurationException.java
+1 −1 src/main/java/uk/ac/ebi/atlas/solr/cloud/collections/BulkAnalyticsCollectionProxy.java
+10 −0 src/main/java/uk/ac/ebi/atlas/testutils/JdbcUtils.java
+0 −78 src/main/java/uk/ac/ebi/atlas/testutils/TestExperiment.java
+0 −87 src/main/java/uk/ac/ebi/atlas/trader/ExperimentDesignDao.java
+0 −14 src/main/java/uk/ac/ebi/atlas/trader/ExperimentDesignData.java
+3 −0 src/main/java/uk/ac/ebi/atlas/trader/ExperimentRepository.java
+4 −0 src/main/java/uk/ac/ebi/atlas/trader/ExperimentTrader.java
+50 −23 src/main/java/uk/ac/ebi/atlas/trader/factory/BaselineExperimentFactory.java
+12 −1 src/test/java/uk/ac/ebi/atlas/configuration/TestConfig.java
+25 −0 src/test/java/uk/ac/ebi/atlas/experimentimport/ExperimentCrudDaoIT.java
+2 −2 src/test/java/uk/ac/ebi/atlas/experimentimport/analyticsindex/AnalyticsIndexerManagerTest.java
+1 −1 src/test/java/uk/ac/ebi/atlas/experimentimport/analyticsindex/DifferentialExperimentDataPointTest.java
+1 −1 src/test/java/uk/ac/ebi/atlas/experimentimport/analyticsindex/stream/BaselineExperimentDataPointTest.java
+1 −1 src/test/java/uk/ac/ebi/atlas/experimentimport/analyticsindex/stream/MicroarrayExperimentDataPointTest.java
+0 −1 src/test/java/uk/ac/ebi/atlas/experimentpage/ExternallyAvailableContentServiceTest.java
+1 −1 src/test/java/uk/ac/ebi/atlas/experimentpage/link/LinkToArrayExpressIT.java
+1 −1 src/test/java/uk/ac/ebi/atlas/experimentpage/link/LinkToEgaIT.java
+1 −1 src/test/java/uk/ac/ebi/atlas/experimentpage/link/LinkToEnaIT.java
+1 −1 src/test/java/uk/ac/ebi/atlas/experimentpage/link/LinkToGeoIT.java
+4 −4 src/test/java/uk/ac/ebi/atlas/experiments/ExperimentJsonSerializerTest.java
+26 −26 src/test/java/uk/ac/ebi/atlas/model/experiment/ExperimentBuilder.java
+71 −3 src/test/java/uk/ac/ebi/atlas/model/experiment/ExperimentTest.java
+1 −1 src/test/java/uk/ac/ebi/atlas/model/experiment/baseline/BaselineExperimentTest.java
+1 −1 src/test/java/uk/ac/ebi/atlas/model/experiment/differential/DifferentialExperimentTest.java
+1 −1 src/test/java/uk/ac/ebi/atlas/model/experiment/singlecell/SingleCellBaselineExperimentTest.java
+0 −59 src/test/java/uk/ac/ebi/atlas/model/experiment/summary/AssayGroupSummaryBuilderTest.java
+0 −50 src/test/java/uk/ac/ebi/atlas/model/experiment/summary/ContrastPropertyTest.java
+0 −89 src/test/java/uk/ac/ebi/atlas/model/experiment/summary/ContrastSummaryBuilderTest.java
+1 −1 src/test/java/uk/ac/ebi/atlas/profiles/ProfileStreamFilterTest.java
+1 −1 src/test/java/uk/ac/ebi/atlas/profiles/differential/microarray/MicroarrayProfileStreamFactoryTest.java
+1 −1 .../java/uk/ac/ebi/atlas/profiles/stream/BulkDifferentialProfileStreamFactoryPickUpExpressionsByIndexTest.java
+1 −1 src/test/java/uk/ac/ebi/atlas/profiles/stream/MicroarrayProfileStreamFactoryReadValuesTest.java
+1 −1 src/test/java/uk/ac/ebi/atlas/profiles/stream/RnaSeqProfileStreamFactoryTest.java
+2 −0 src/test/java/uk/ac/ebi/atlas/solr/analytics/query/AnalyticsQueryClientIT.java
+0 −89 src/test/java/uk/ac/ebi/atlas/trader/ExperimentDesignDaoIT.java
+28 −1 src/test/java/uk/ac/ebi/atlas/trader/ExperimentTraderTest.java
+72 −34 src/test/java/uk/ac/ebi/atlas/trader/factory/BaselineExperimentFactoryTest.java
+0 −9 src/test/java/uk/ac/ebi/atlas/trader/factory/SingleCellBaselineExperimentFactoryTest.java
+0 −1 src/test/resources/fixtures/scxa/scxa_exp_design-delete.sql
+0 −300 src/test/resources/fixtures/scxa/scxa_exp_design.sql
+0 −1 src/test/resources/fixtures/scxa/scxa_exp_design_column-delete.sql
+0 −15 src/test/resources/fixtures/scxa/scxa_exp_design_column.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ repositories {
}

dependencies {
implementation 'io.swagger.core.v3:swagger-core:2.1.11'

implementation 'javax.inject:javax.inject:1'
implementation 'javax.annotation:javax.annotation-api:1.3.2'
// Needs to match Tomcat version https://tomcat.apache.org/whichversion.html
Expand Down
File renamed without changes.
51 changes: 51 additions & 0 deletions docker/docker-compose-openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: "3.6"

services:
scxa-gradle:
image: openjdk:11
container_name: scxa-gradle
networks:
- scxa
ports:
- "8081:8081"
working_dir: /root/project
volumes:
- root-gradle-wrapper:/root/.gradle/wrapper
- root-gradle-caches:/root/.gradle/caches
- ..:/root/project
- ./packages:/root/.m2
- $GRADLE_RO_DEP_CACHE:/gradle-ro-dep-cache
- $ATLAS_EXPERIMENTS_PATH:/sc-experiments
- $ATLAS_BIOENTITY_PROPERTIES_PATH:/atlas-data/bioentity_properties

depends_on:
- scxa-postgres
- scxa-solrcloud-1
- scxa-solrcloud-2
environment:
POSTGRES_HOST: $POSTGRES_HOST
POSTGRES_DB: $POSTGRES_DB
POSTGRES_USER: $POSTGRES_USER
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
GRADLE_RO_DEP_CACHE: /gradle-ro-dep-cache
command:
- sh
- -c
- >
./gradlew
-PdataFilesLocation=/atlas-data
-PexperimentFilesLocation=/sc-experiments
-PjdbcUrl=jdbc:postgresql://$POSTGRES_HOST:5432/$POSTGRES_DB
-PjdbcUsername=$POSTGRES_USER
-PjdbcPassword=$POSTGRES_PASSWORD
-PzkHost=scxa-zk-1
-PsolrHost=scxa-solrcloud-1
clean :openapi:bootRun

volumes:
root-gradle-wrapper:
root-gradle-caches:

networks:
scxa:
name: scxa
54 changes: 0 additions & 54 deletions docker/tomcat-users.xml

This file was deleted.

55 changes: 55 additions & 0 deletions openapi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Open API

This subproject generates Open API documentation for all controllers in `app` and `atlas-web-ocre` subprojects. It is
powered by [springdoc-openapi](https://springdoc.org/) and
[its Gradle plugin](https://github.com/springdoc/springdoc-openapi-gradle-plugin). It is a Spring Boot minimal web app
that includes the two mentioned projects and finds all the relevant URLs by virtue of package scanning.

## Requirements
- Java 11
- Expression Atlas environment (PostgreSQL server; SolrCloud cluster; bioentity annotation and experiment files)

## Usage
### Swagger UI
```bash
./gradlew :openapi:bootRun
```

Launch your browser and point it at `http://localhost:8081/swagger-ui.html`. Also, you can find your API docs at
`http://localhost:8081/v3/api-docs.yaml` (YAML) or `http://localhost:8081/v3/api-docs` (JSON).

### Generate API docs
```bash
./gradlew :openapi:generateOpenApiDocs
```

Find your Open API doc at `openapi/build/openapi.yaml`.

## Configuration
Configuration variables are set with `-Dproperty=value` if you run the application via `java -jar ...`, or by adding
`-Pproperty=value` to the Gradle task (in the tables below: Java property name, and Gradle propery name, respectively).

**IMPORTANT**: At the very least you will need to set the environment variables described in the Default value columns
to run/compile the application with Gradle. However, notice that the `-D` arguments will override whatever was set at
compile time, so if you forget or your environment changes, you don’t need to recompile.

### Expression Atlas file options: `configuration.properties`
| Java property name | Gradle property name | Default value |
|-----------------------------|---------------------------|-----------------------------|
| `data.files.location` | `dataFilesLocation` | `${ATLAS_DATA_PATH}` |
| `experiment.files.location` | `experimentFilesLocation` | `${ATLAS_EXPERIMENTS_PATH}` |

### Expression Atlas database options: `jdbc.properties`
| Java Property name | Gradle property name | Default value |
|--------------------|----------------------|---------------------------------------------------------------------|
| `jdbc.url` | `jdbcUrl` | `jdbc:postgresql://${ATLAS_POSTGRES_HOST}:5432/${ATLAS_POSTGRES_DB` |
| `jdbc.username` | `jdbcUsername` | `${ATLAS_POSTGRES_USER}` |
| `jdbc.password` | `jdbcPassword` | `${ATLAS_POSTRES_PASSWORD}` |

### Expression Atlas Solr options: `solr.properties`
| Java property name | Gradle property name | Default value |
|--------------------|----------------------|----------------------|
| `zk.host` | `zkHost` | `${ATLAS_ZK_HOST}` |
| `zk.port` | `zkPort` | `2181` |
| `solr.host` | `solrHost` | `${ATLAS_SOLR_HOST}` |
| `solr.port` | `solrPort` | `8983` |
Loading
Loading