This server implements all BrAPI calls. It is backed by a custom database with dummy data.
- BrAPI V1 Base URL (v1.0, v1.1, v1.2, v1.3): test-server.brapi.org/brapi/v1/
- BrAPI V2 Base URL (v2.0, v2.1): test-server.brapi.org/brapi/v2/
Use /calls (V1) or /serverinfo (V2) to check the available endpoints.
- Maven 3.9
- Java 21
- Postgres 17.2
BrAPI has provided a sample central authentication service for the test server.
Here you can create a user and login to be presented with a token which can be used to make requests to your sample server implementation.
Why offer auth? Apart from security concerns, you can utilize authentication with the BrAPI spec to deliver extra functionality tailored to what data you want your users to see.
To utilize the sample central auth service, set the following properties in your application.properties
file:
security.oidc_discovery_url=https://test-server.brapi.org/.well-known/openid-configuration
security.issuer_urlhttps://auth.brapi.org/realms/brapi
If you are not using the sample BrAPI auth system, you must configure these variables properly with the endpoints they expect for your service.
The local authorization docker set up has some details about how to find these values.
For instructions on how to send the authentication token in your request, see this section.
For more information detailing the authentication of the BrAPI Test Server, more documentation with examples and diagrams can be found here
e742f19 (Merge pull request #76 from plantbreeding/java-21-upgrade)
- Checkout the project and open in your favorite Java IDE.
- Run maven to clean and install dependencies
mvn clean install
- Setup an empty database server (Postgres is recommended). Create a new database schema, but do not add any tables. The tables and data will be added on server startup.
- Copy
/src/main/resources/application.properties.template
to/src/main/resources/properties/application.properties
- Edit
application.properties
- Change
server.port
andserver.servlet.context-path
as needed - Change the
spring.datasource.
parameters to match your empty database server and schema - If you did not use a Postgres database, change the
spring.datasource.driver-class
to match the database type you have setup (this may require additional dependancies in the POM)
- Change
- Run
org.brapi.test.BrAPITestServer.BrapiTestServer.java
- Setup an empty database server (Postgres is recommended). Create a new database schema, but do not add any tables. The tables and data will be added on server startup.
- Download application.properties.template and rename the file
application.properties
- Save this file on the docker host as
/<Local_Path_To_Properties>/application.properties
- Edit
application.properties
- Change
server.port
andserver.servlet.context-path
as needed (port 8080 is exposed in the dockerfile by default) - Change the
spring.datasource.
parameters to match your empty database server and schema - If you did not use a Postgres database, change the
spring.datasource.driver-class
to match the database type you have setup (this may require additional dependancies in the POM, and a fresh build of the docker image)
- Change
- Docker Pull
docker pull brapicoordinatorselby/brapi-java-server:v2
- Docker Run
docker run -v /<Local_Path_To_Properties>/:/home/brapi/properties -d brapicoordinatorselby/brapi-java-server:v2
The database is created automatically at run time by flyway.
SQL-based migrations under src/main/resources/db/migration
or src/main/resources/db/sql
, and Java-based migrations under src/main/java/org/brapi/test/BrAPITestServer/db/migration
will be run.
The src/main/resources/db/migration
directory is for schema changes, while src/main/resources/db/sql
is for seed data. Modify spring.flyway.locations
in application.properties
to change what flyway runs.
When running in Docker, you can edit or add seed data by adding the volume -v /<Local_Path_To_SQL>/:/home/brapi/sql
to your docker command.
Below is a UML diagram of the whole database schema: