Skip to content

Springdoc

Project Dependencies

Add the following dependency to your pom.xml/build.gradle file:

implementation("com.raynigon.unit-api:spring-boot-springdoc-starter:3.0.8")
<dependency>
    <groupId>com.raynigon.unit-api</groupId>
    <artifactId>spring-boot-springdoc-starter</artifactId>
    <version>3.0.8</version>
</dependency>

Usage

To view documentation generated from your data model create an Entity which should contain @JsonUnit annotations. This model has then to be used in the controller as either request or response.

data class TelemetryRecordRequest(

    @JsonUnit(MilliSecond::class)
    val rtt: Quantity<Time>,
    val fuel: TelemetryFuel,
    val sensors: TelemetrySensors,
    val energy: TelemetryEnergy,
    val computer: TelemetryComputer
)

data class TelemetryFuel(
    val nto: Quantity<Mass>,
    val hydrazine: Quantity<Mass>
)
Rebuild the application and check the swagger documentation generated by springdoc. This is usually located at http://localhost:8080/swagger-ui.html. The schema will now contain a description with a valid unit foreach Quantity<?> property.