Add documentation annotations to /v1/config

This commit is contained in:
Chris Eager 2025-01-02 12:46:44 -06:00 committed by Chris Eager
parent 95abda4870
commit 24ea10c451
3 changed files with 28 additions and 5 deletions

View File

@ -7,6 +7,8 @@ package org.whispersystems.textsecuregcm.controllers;
import com.google.common.annotations.VisibleForTesting;
import io.dropwizard.auth.Auth;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@ -52,6 +54,16 @@ public class RemoteConfigController {
@GET
@Produces(MediaType.APPLICATION_JSON)
@Operation(
summary = "Fetch remote configuration",
description = """
Remote configuration is a list of namespaced keys that clients may use for consistent configuration or behavior.
Configuration values change over time, and the list should be refreshed periodically, typically at client
launch and every few hours thereafter.
"""
)
@ApiResponse(responseCode = "200", description = "Remote configuration values for the authenticated user", useReturnTypeSchema = true)
public UserRemoteConfigList getAll(@ReadOnly @Auth AuthenticatedDevice auth) {
try {
MessageDigest digest = MessageDigest.getInstance("SHA1");

View File

@ -6,24 +6,29 @@
package org.whispersystems.textsecuregcm.entities;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
public class UserRemoteConfig {
@JsonProperty
private String name;
@Schema(description = "Name of the configuration", example = "android.exampleFeature")
private String name;
@JsonProperty
@Schema(description = "Whether the configuration is enabled for the user")
private boolean enabled;
@JsonProperty
private String value;
@Schema(description = "The value to be used for the configuration, if it is a non-boolean type")
private String value;
public UserRemoteConfig() {}
public UserRemoteConfig() {
}
public UserRemoteConfig(String name, boolean enabled, String value) {
this.name = name;
this.name = name;
this.enabled = enabled;
this.value = value;
this.value = value;
}
public String getName() {

View File

@ -10,16 +10,22 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.time.Instant;
import java.util.List;
import io.swagger.v3.oas.annotations.media.Schema;
import org.whispersystems.textsecuregcm.util.InstantAdapter;
public class UserRemoteConfigList {
@JsonProperty
@Schema(description = "List of remote configurations applicable to the user")
private List<UserRemoteConfig> config;
@JsonProperty
@JsonSerialize(using = InstantAdapter.EpochSecondSerializer.class)
@JsonFormat(shape = JsonFormat.Shape.NUMBER_INT)
@Schema(description = """
Timestamp when the configuration was generated. Deprecated in favor of `X-Signal-Timestamp` response header.
""", deprecated = true)
@Deprecated
private Instant serverEpochTime;
public UserRemoteConfigList() {}