Skip to content

Spring Boot Sample

Run the complete Sample with 27 Swagger operations, safety gates, and MQ examples.

This Sample shows how to configure Station OpenAPI SDK in Spring Boot 3, run Swagger UI, call all 27 HTTP operations, and integrate RocketMQ messages.

Use the main module for the first integration. The native MQ module is only for applications that do not use RocketMQ Starter.

Demonstration Only — Not for Production

This Sample exists solely to demonstrate SDK integration. It is not a production-ready application and does not provide the complete authentication, authorization, persistence, auditing, monitoring, high-availability, disaster-recovery, or security controls required by a production system.

Do not deploy or use the Sample for real production workloads without completing the necessary production design, development, security assessment, and comprehensive testing. Any production incident, unintended device operation, service interruption, data loss, corruption or disclosure, credential exposure, or other direct or indirect loss resulting from such use is solely the user’s responsibility. The project provider and maintainers accept no liability.

Prepare the following:

ItemRequirement
JDK17 or later
Maven3.9 or later
IDEIntelliJ IDEA
Station endpointRoot http:// or https:// address supplied by technical support
AuthenticationAccess Token, or AppKey and SecretKey
RocketMQNameServer and message permissions, only when the MQ example is enabled

Contact your assigned technical support representative before starting to obtain the endpoint and one authentication method. Without them, the Sample can compile but cannot call the Station platform.

The platform environment supplied by technical support is compatible with the SDK, so you do not need to select a platform version.

The Sample is an independent Maven project with two modules:

ModulePurpose
station-openapi-sample-spring-bootHTTP, Swagger UI, validation, dangerous-operation protection, and Starter MQ
station-openapi-sample-native-mqSDK native RocketMQ Subscriber example

The Sample depends on the project’s 1.0.0-SNAPSHOT SDK. Before the first run:

  1. Open the repository root pom.xml in IDEA;
  2. Set both Project SDK and Maven Runner JRE to JDK 17;
  3. In the Maven tool window, select the root project and run Lifecycle > install;
  4. After installation, add samples/station-openapi-spring-boot-sample/pom.xml in the Maven tool window;
  5. Wait for IDEA to finish the Maven reload.

If the customer team has already published the SDK to a private Nexus, make sure the Sample POM version matches the version in that repository.

The main module uses Token authentication by default. The minimum startup configuration is the endpoint plus the credentials for one mode.

Open:

station-openapi-sample-spring-boot/src/main/resources/application.yml

Confirm that the active profile is token and replace the endpoint with the value supplied by technical support:

spring:
profiles:
active: token
station:
openapi:
endpoint: http://station.example.com

Then open application-token.yml and enter the Access Token:

station:
openapi:
auth-mode: ACCESS_TOKEN
access-token: "<Access Token supplied by technical support>"

Change the active profile in application.yml to signature:

spring:
profiles:
active: signature
station:
openapi:
endpoint: http://station.example.com

Then open application-signature.yml and enter:

station:
openapi:
auth-mode: SIGNATURE
app-key: "<AppKey supplied by technical support>"
secret-key: "<SecretKey supplied by technical support>"

Configure only the credentials required by the active mode. Token mode must not contain AppKey/SecretKey, and signature mode must not contain an Access Token.

These edits are for local evaluation only. Never commit real credentials to a public repository.

Run the main class:

com.deeprobotics.station.openapi.sample.StationOpenApiSampleApplication

After startup, open:

PageAddress
Swagger UIhttp://localhost:8080/swagger-ui/index.html
OpenAPI JSONhttp://localhost:8080/v3/api-docs

Call this operation first in Swagger:

POST /sample/api/system/get-time-text

It does not modify platform data and verifies the endpoint, network, and authentication. After it succeeds, continue with a query in the Inventory group.

Swagger exposes 27 operations:

GroupCountContents
Inventory8Quadruped robots, maps, camera streams, inspection points, maintenance areas, road maps, docks, and nodes
Dog6Status, charging, control, target position, alarms, and real-time position
Camera2Camera control and PTZ reset
Task Template4Create, delete, details, and page query
Task4Issue, control, batch cancellation, and execution page query
Result2Inspection result page query and resource download
System1Platform time
Total27

Each Swagger operation maps to one explicit SDK call. The complete call examples are under:

station-openapi-sample-spring-boot/src/main/java/
com/deeprobotics/station/openapi/sample/service/

The seven services inject StationOpenApiClient directly and call the SDK. Use them as references when implementing your own business services.

The following ten operations modify platform data or control field equipment. The Sample returns HTTP 403 before calling the SDK:

Sample pathPurpose
/sample/api/dog/charge-controlControl return-to-charge behavior
/sample/api/dog/controlControl a quadruped robot
/sample/api/dog/set-positionSend a target position
/sample/api/camera/controlControl a camera
/sample/api/camera/reset-ptzReset PTZ
/sample/api/task-template/createCreate a task template
/sample/api/task-template/delete-by-codesDelete task templates
/sample/api/task/issueIssue a task
/sample/api/task/controlControl a task
/sample/api/task/batch-cancelCancel tasks in a batch

Enable them only after confirming the target device and test operation. Set this property in application.yml:

sample:
dangerous-operations-enabled: true

Restart the application after changing it, and restore false after the evaluation.

This switch prevents accidental operations in the Sample only. Your own APIs still need business-appropriate access controls.

  • Objects, lists, and pages return 200 OK.
  • SDK void results and an empty real-time position return 204 No Content.
  • Downloads use StreamingResponseBody.
  • Validation and SDK errors return application/problem+json.
  • Pagination requests use pageNo, never pageNum.
  • Camera query responses never expose passwords through Swagger.
  • resultUnknown=true means a write or control result has not been confirmed. Query the state before repeating the operation.

Error messages support zh_CN and en_US. The lang query parameter overrides Accept-Language; Chinese is used when no language is specified.

The HTTP Sample runs without RocketMQ. Configure MQ only when platform messages are required.

Obtain the NameServer address and message permissions from technical support. See RocketMQ Message Integration for configuration.

The main module uses RocketMQ Starter. Its Listener delegates to the SDK’s RemoteMessageRouter and supports task status, inspection results, quadruped robot alarms, and inspection routes.

station-openapi-sample-native-mq demonstrates the SDK native Subscriber only. It does not provide HTTP or Swagger and does not require a Token, AppKey, or SecretKey.

To run it:

  1. Enter the NameServer and consumer group in the module’s application.yml;
  2. Set station.openapi.native-mq.enabled to true;
  3. Run NativeMqSampleApplication in IDEA.

See RocketMQ Message Integration for the complete configuration.

ContentFile
SDK propertiesStationOpenApiProperties.java
Singleton Client beanStationOpenApiConfiguration.java
Seven SDK service groupsservice
Swagger controllersweb
Starter MQ ListenerStarterRemoteMessageListener.java
Native Subscriber beanNativeMqConfiguration.java

Startup Reports a Missing Endpoint or Credential

Section titled “Startup Reports a Missing Endpoint or Credential”

Confirm that application.yml activates either token or signature, and that all properties required by that mode are present.

Clear AppKey and SecretKey in Token mode. Clear the Access Token in signature mode, then restart the application.

An accessible Swagger page only confirms that the local application started. Check that the endpoint, network, and credentials all belong to the same environment supplied by technical support.

This is the Sample’s default protection. Enable the switch in Section 6 and restart only when an operation must be demonstrated.

Run Lifecycle > install for the root project in IDEA’s Maven tool window, then reload the Sample Maven project.

Confirm that the MQ switch, NameServer, and consumer group are configured. Ask technical support to verify the topic, message permissions, and Broker network.