Browse Source

Fix OpenAPI response types of claimDevice, getPersistedRpcByDevice and exportIntegrationPackage

claimDevice returns ClaimResult and getPersistedRpcByDevice returns
PageData<Rpc>, but both were documented as a string, so generated
clients failed to decode every successful response. getPersistedRpcByDevice
returns a raw DeferredResult<ResponseEntity>, so a doc-only PageDataRpc
describes its body. exportIntegrationPackage returns application/zip,
not a JSON string.
pull/16510/head
Vladyslav_Prykhodko 4 weeks ago
parent
commit
f8ebcbf67c
  1. 4
      application/src/main/java/org/thingsboard/server/controller/DeviceController.java
  2. 4
      application/src/main/java/org/thingsboard/server/controller/IntegrationController.java
  3. 11
      application/src/main/java/org/thingsboard/server/controller/RpcV2Controller.java

4
application/src/main/java/org/thingsboard/server/controller/DeviceController.java

@ -10,7 +10,9 @@ import com.google.common.util.concurrent.MoreExecutors;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.annotation.Nullable;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
@ -583,6 +585,8 @@ public class DeviceController extends BaseController {
"In order to enable claiming devices feature a system parameter security.claim.allowClaimingByDefault should be set to true, " +
"otherwise a server-side claimingAllowed attribute with the value true is obligatory for provisioned devices. \n" +
"See official documentation for more details regarding claiming." + CUSTOMER_AUTHORITY_PARAGRAPH + RBAC_CLAIM_CHECK)
@ApiResponse(responseCode = "200", description = "OK",
content = @Content(schema = @Schema(implementation = ClaimResult.class)))
@PreAuthorize("hasAuthority('CUSTOMER_USER')")
@RequestMapping(value = "/customer/device/{deviceName}/claim", method = RequestMethod.POST)
@ResponseBody

4
application/src/main/java/org/thingsboard/server/controller/IntegrationController.java

@ -5,7 +5,9 @@ package org.thingsboard.server.controller;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
@ -479,6 +481,8 @@ public class IntegrationController extends AutoCommitController {
notes = "Returns a ZIP containing integration.json, uplink.json, optional downlink.json, "
+ "and form.json. Sensitive fields are tokenized via @TemplateField annotations on "
+ "the integration's runtime POJO.")
@ApiResponse(responseCode = "200", description = "OK",
content = @Content(mediaType = "application/zip", schema = @Schema(type = "string", format = "binary")))
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@GetMapping("/integration/{integrationId}/export-package")
public ResponseEntity<byte[]> exportIntegrationPackage(

11
application/src/main/java/org/thingsboard/server/controller/RpcV2Controller.java

@ -160,6 +160,8 @@ public class RpcV2Controller extends AbstractRpcController {
}
@ApiOperation(value = "Get persistent RPC requests", notes = "Allows to query RPC calls for specific device using pagination." + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
@ApiResponse(responseCode = "200", description = "OK",
content = @Content(schema = @Schema(implementation = PageDataRpc.class)))
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/persistent/device/{deviceId}", method = RequestMethod.GET)
@ResponseBody
@ -244,4 +246,13 @@ public class RpcV2Controller extends AbstractRpcController {
tbClusterService.pushMsgToRuleEngine(getTenantId(), rpc.getDeviceId(), msg, null);
}
}
/**
* Documents the {@code PageData<Rpc>} that {@link #getPersistedRpcByDevice} returns
* through a {@code DeferredResult<ResponseEntity>}. Used only by the OpenAPI spec.
*/
@Schema(name = "PageDataRpc")
private static final class PageDataRpc extends PageData<Rpc> {
}
}

Loading…
Cancel
Save