Skip to content

Commit b30ae3b

Browse files
committed
add missing OpenAPI descriptions
1 parent 788c875 commit b30ae3b

File tree

4 files changed

+75
-1
lines changed

4 files changed

+75
-1
lines changed

src/main/java/de/rwth/idsg/steve/repository/dto/OcppTag.java

+15
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,22 @@ public final class OcppTag {
3636
@Builder
3737
@ToString
3838
public static final class Overview {
39+
@Schema(description = "PK of the OCPP tag")
3940
private final Integer ocppTagPk;
41+
42+
@Schema(description = "The OCPP tag")
4043
private final String idTag;
4144

45+
@Schema(description = "PK of the parent OCPP tag of this OCPP tag")
4246
private final Integer parentOcppTagPk;
47+
48+
@Schema(description = "The parent OCPP tag of this OCPP tag")
4349
private final String parentIdTag;
4450

51+
@Schema(description = "Has the OCPP tag active transactions (i.e. ongoing charging sessions)?")
4552
private final boolean inTransaction;
53+
54+
@Schema(description = "Is the OCPP tag blocked?")
4655
private final boolean blocked;
4756

4857
/**
@@ -52,10 +61,16 @@ public static final class Overview {
5261
@Schema(hidden = true)
5362
private final String expiryDateFormatted;
5463

64+
@Schema(description = "The date/time at which the OCPP tag will expire (if set)")
5565
private final DateTime expiryDate;
5666

67+
@Schema(description = "The maximum number of active transactions allowed for this OCPP tag")
5768
private final Integer maxActiveTransactionCount;
69+
70+
@Schema(description = "The number of currently active transactions for this OCPP tag")
5871
private final Long activeTransactionCount;
72+
73+
@Schema(description = "An additional note")
5974
private final String note;
6075
}
6176
}

src/main/java/de/rwth/idsg/steve/repository/dto/Transaction.java

+20
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,32 @@
3232
* @author Sevket Goekay <[email protected]>
3333
*
3434
*/
35+
@Schema(description = """
36+
For active transactions, all 'stop'-prefixed fields would be null.
37+
The energy consumed during the transaction can be calculated by subtracting the 'startValue' from the 'stopValue'.
38+
The unit of the 'startValue' and 'stopValue' is watt-hours (Wh).
39+
""")
3540
@Getter
3641
@Builder
3742
@ToString
3843
public final class Transaction {
3944

45+
@Schema(description = "PK of the transaction")
4046
private final int id;
47+
48+
@Schema(description = "Connector ID of the charge box at which the transaction took place")
4149
private final int connectorId;
50+
51+
@Schema(description = "PK of the charge box at which the transaction took place")
4252
private final int chargeBoxPk;
53+
54+
@Schema(description = "PK of the OCPP tag used in the transaction")
4355
private final int ocppTagPk;
4456

57+
@Schema(description = "The identifier of the charge box at which the transaction took place")
4558
private final String chargeBoxId;
4659

60+
@Schema(description = "The Ocpp Tag used in the transaction")
4761
private final String ocppIdTag;
4862

4963
/**
@@ -53,8 +67,10 @@ public final class Transaction {
5367
@Schema(hidden = true)
5468
private final String startTimestampFormatted;
5569

70+
@Schema(description = "The meter value reading at the start of the transaction")
5671
private final String startValue;
5772

73+
@Schema(description = "The timestamp at which the transaction started")
5874
private final DateTime startTimestamp;
5975

6076
/**
@@ -66,14 +82,18 @@ public final class Transaction {
6682
private final String stopTimestampFormatted;
6783

6884
@Nullable
85+
@Schema(description = "The meter value reading at the end of the transaction")
6986
private final String stopValue;
7087

7188
@Nullable
89+
@Schema(description = "The reason for the transaction being stopped")
7290
private final String stopReason; // new in OCPP 1.6
7391

7492
@Nullable
93+
@Schema(description = "The timestamp at which the transaction ended")
7594
private final DateTime stopTimestamp;
7695

7796
@Nullable
97+
@Schema(description = "The actor who stopped the transaction")
7898
private final TransactionStopEventActor stopEventActor;
7999
}

src/main/java/de/rwth/idsg/steve/web/api/OcppTagsRestController.java

+28-1
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
import de.rwth.idsg.steve.web.api.ApiControllerAdvice.ApiErrorResponse;
2525
import de.rwth.idsg.steve.web.dto.OcppTagForm;
2626
import de.rwth.idsg.steve.web.dto.OcppTagQueryForm;
27+
import io.swagger.v3.oas.annotations.Operation;
2728
import io.swagger.v3.oas.annotations.media.Content;
2829
import io.swagger.v3.oas.annotations.media.Schema;
2930
import io.swagger.v3.oas.annotations.responses.ApiResponse;
3031
import io.swagger.v3.oas.annotations.responses.ApiResponses;
32+
import io.swagger.v3.oas.annotations.tags.Tag;
3133
import lombok.RequiredArgsConstructor;
3234
import lombok.extern.slf4j.Slf4j;
3335
import org.springframework.http.HttpStatus;
@@ -50,6 +52,14 @@
5052
* @author Sevket Goekay <[email protected]>
5153
* @since 13.09.2022
5254
*/
55+
@Tag(name = "ocpp-tag-controller",
56+
description = """
57+
Operations related to managing Ocpp Tags.
58+
An Ocpp Tag is the identifier of the actor that interacts with the charge box.
59+
It can be used for authorization, but also to start and stop charging sessions.
60+
An RFID card is an example of an Ocpp Tag.
61+
"""
62+
)
5363
@Slf4j
5464
@RestController
5565
@RequestMapping(value = "/api/v1/ocppTags", produces = MediaType.APPLICATION_JSON_VALUE)
@@ -58,7 +68,10 @@ public class OcppTagsRestController {
5868

5969
private final OcppTagService ocppTagService;
6070

61-
71+
@Operation(description = """
72+
Returns a list of Ocpp Tags based on the query parameters.
73+
The query parameters can be used to filter the Ocpp Tags.
74+
""")
6275
@ApiResponses(value = {
6376
@ApiResponse(responseCode = "200", description = "OK"),
6477
@ApiResponse(responseCode = "400", description = "Bad Request", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ApiErrorResponse.class))}),
@@ -75,6 +88,9 @@ public List<OcppTag.Overview> get(OcppTagQueryForm.ForApi params) {
7588
return response;
7689
}
7790

91+
@Operation(description = """
92+
Returns a single Ocpp Tag based on the ocppTagPk.
93+
""")
7894
@ApiResponses(value = {
7995
@ApiResponse(responseCode = "200", description = "OK"),
8096
@ApiResponse(responseCode = "400", description = "Bad Request", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ApiErrorResponse.class))}),
@@ -92,6 +108,10 @@ public OcppTag.Overview getOne(@PathVariable("ocppTagPk") Integer ocppTagPk) {
92108
return response;
93109
}
94110

111+
@Operation(description = """
112+
Creates a new Ocpp Tag with the provided parameters.
113+
The request body should contain the necessary information.
114+
""")
95115
@ApiResponses(value = {
96116
@ApiResponse(responseCode = "201", description = "Created"),
97117
@ApiResponse(responseCode = "400", description = "Bad Request", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ApiErrorResponse.class))}),
@@ -113,6 +133,9 @@ public OcppTag.Overview create(@RequestBody @Valid OcppTagForm params) {
113133
return response;
114134
}
115135

136+
@Operation(description = """
137+
Updates an existing Ocpp Tag with the provided parameters.
138+
""")
116139
@ApiResponses(value = {
117140
@ApiResponse(responseCode = "200", description = "OK"),
118141
@ApiResponse(responseCode = "400", description = "Bad Request", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ApiErrorResponse.class))}),
@@ -133,6 +156,10 @@ public OcppTag.Overview update(@PathVariable("ocppTagPk") Integer ocppTagPk, @Re
133156
return response;
134157
}
135158

159+
@Operation(description = """
160+
Deletes an existing Ocpp Tag based on the ocppTagPk.
161+
Returns the deleted Ocpp Tag.
162+
""")
136163
@ApiResponses(value = {
137164
@ApiResponse(responseCode = "200", description = "OK"),
138165
@ApiResponse(responseCode = "400", description = "Bad Request", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ApiErrorResponse.class))}),

src/main/java/de/rwth/idsg/steve/web/api/TransactionsRestController.java

+12
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
import de.rwth.idsg.steve.web.api.ApiControllerAdvice.ApiErrorResponse;
2424
import de.rwth.idsg.steve.web.api.exception.BadRequestException;
2525
import de.rwth.idsg.steve.web.dto.TransactionQueryForm;
26+
import io.swagger.v3.oas.annotations.Operation;
2627
import io.swagger.v3.oas.annotations.media.Content;
2728
import io.swagger.v3.oas.annotations.media.Schema;
2829
import io.swagger.v3.oas.annotations.responses.ApiResponse;
2930
import io.swagger.v3.oas.annotations.responses.ApiResponses;
31+
import io.swagger.v3.oas.annotations.tags.Tag;
3032
import lombok.RequiredArgsConstructor;
3133
import lombok.extern.slf4j.Slf4j;
3234
import org.springframework.http.MediaType;
@@ -42,6 +44,12 @@
4244
* @author Sevket Goekay <[email protected]>
4345
* @since 13.09.2022
4446
*/
47+
@Tag(name = "transaction-controller",
48+
description = """
49+
Operations related to querying transactions.
50+
A transaction represents a charging session at a charge box (i.e. charging station. The notions 'charge box' and 'charging station' are being used interchangeably).
51+
"""
52+
)
4553
@Slf4j
4654
@RestController
4755
@RequestMapping(value = "/api/v1/transactions", produces = MediaType.APPLICATION_JSON_VALUE)
@@ -50,6 +58,10 @@ public class TransactionsRestController {
5058

5159
private final TransactionRepository transactionRepository;
5260

61+
@Operation(description = """
62+
Returns a list of transactions based on the query parameters.
63+
The query parameters can be used to filter the transactions.
64+
""")
5365
@ApiResponses(value = {
5466
@ApiResponse(responseCode = "200", description = "OK"),
5567
@ApiResponse(responseCode = "400", description = "Bad Request", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ApiErrorResponse.class))}),

0 commit comments

Comments
 (0)