Skip to content

Commit

Permalink
APPS-886 APPS-887 Fix Swagger models (#147)
Browse files Browse the repository at this point in the history
* fix: APPS-886 APPS-887 missing details in swagger docs

* refactor: Replace deprecated Schema.required with requiredMode

* code format

---------

Co-authored-by: yrizhkov <[email protected]>
  • Loading branch information
jdogmcsteezy and reugn authored Sep 18, 2023
1 parent 92676da commit 55d5bd8
Show file tree
Hide file tree
Showing 152 changed files with 1,610 additions and 1,338 deletions.
33 changes: 18 additions & 15 deletions src/main/java/com/aerospike/restclient/domain/RestClientError.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,14 @@ public class RestClientError {

@Schema(
description = "A boolean specifying whether it was possible that the operation succeeded. This is only included if true.",
required = true,
requiredMode = Schema.RequiredMode.REQUIRED,
example = "false"
)
private final Boolean inDoubt;

@Schema(description = "An internal error code for diagnostic purposes. This may be null", example = "-3")
private final Integer internalErrorCode;

public String getMessage() {
return message;
}

public Boolean getInDoubt() {
return inDoubt;
}

public Integer getInternalErrorCode() {
return internalErrorCode;
}

public RestClientError(AerospikeException ex) {
this.message = ex.getMessage();
this.inDoubt = ex.getInDoubt();
Expand All @@ -68,10 +56,25 @@ public RestClientError(String message) {
}

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public RestClientError(@JsonProperty("message") String message, @JsonProperty("inDoubt") boolean inDoubt,
@JsonProperty("internalErrorCode") int internalErrorCode) {
public RestClientError(
@JsonProperty("message") String message,
@JsonProperty("inDoubt") boolean inDoubt,
@JsonProperty("internalErrorCode") int internalErrorCode
) {
this.message = message;
this.inDoubt = inDoubt;
this.internalErrorCode = internalErrorCode;
}

public String getMessage() {
return message;
}

public Boolean getInDoubt() {
return inDoubt;
}

public Integer getInternalErrorCode() {
return internalErrorCode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

public class RestClientKey {

@Schema(required = true, example = "testNS")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, example = "testNS")
public String namespace;

@JsonProperty(value = "setName")
Expand All @@ -46,7 +46,7 @@ public class RestClientKey {
public RecordKeyType keyType;

@Schema(
required = true,
requiredMode = Schema.RequiredMode.REQUIRED,
description = "The user key, it may be a string, integer, or URL safe Base64 encoded bytes.",
example = "userKey"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ public RestClientKeyRecord(Key key, Record rec) {
bins = rec.bins;
}

@Schema(required = true,
@Schema(
requiredMode = Schema.RequiredMode.REQUIRED,
description = "The user key, it may be a string, integer, or URL safe Base64 encoded bytes.",
example = "userKey")
example = "userKey"
)
public Object userKey;

@Schema(name = "generation", description = "The generation of the record.", example = "2")
Expand All @@ -48,7 +50,10 @@ public RestClientKeyRecord(Key key, Record rec) {
@Schema(name = "ttl", description = "The time to live for the record, in seconds from now.", example = "1000")
public int ttl;

@Schema(name = "bins", description = "A mapping from binName to binValue",
example = "{\"bin1\": \"val1\", \"pi\": \"3.14\"}")
@Schema(
name = "bins",
description = "A mapping from binName to binValue",
example = "{\"bin1\": \"val1\", \"pi\": \"3.14\"}"
)
public Map<String, Object> bins;
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ public RestClientOperation(Map<String, Object> opMap) {
}

@Schema(
required = true, description = "Aerospike operation to perform on the record", example = "LIST_APPEND_ITEMS"
requiredMode = Schema.RequiredMode.REQUIRED,
description = "Aerospike operation to perform on the record",
example = "LIST_APPEND_ITEMS"
)
private AerospikeOperation operation;

@Schema(required = true, example = "{\"bin\":\"listbin\", \"values\":[1,2,3]}")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, example = "{\"bin\":\"listbin\", \"values\":[1,2,3]}")
private Map<String, Object> opValues;

public AerospikeOperation getOperation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class RestClientPrivilege {

@NotNull
@Schema(required = true)
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
PrivilegeCode code;

@Schema(description = "Namespace Scope", example = "testNS")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
public class RestClientRole {

@NotNull
@Schema(required = true, description = "Role name.", example = "customRole")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Role name.", example = "customRole")
private String name;

@NotNull
@Schema(required = true, description = "List of assigned privileges.")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "List of assigned privileges.")
private List<RestClientPrivilege> privileges;

@Schema(description = "List of allowable IP addresses.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
public class BatchDelete extends BatchRecord {
@Schema(
description = "The type of batch request. It is always " + AerospikeAPIConstants.BATCH_TYPE_DELETE,
allowableValues = AerospikeAPIConstants.BATCH_TYPE_DELETE,
required = true
allowableValues = {AerospikeAPIConstants.BATCH_TYPE_DELETE},
requiredMode = Schema.RequiredMode.REQUIRED
)
public final String type = AerospikeAPIConstants.BATCH_TYPE_DELETE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
public class BatchRead extends BatchRecord {
@Schema(
description = "The type of batch request. It is always " + AerospikeAPIConstants.BATCH_TYPE_READ,
allowableValues = AerospikeAPIConstants.BATCH_TYPE_READ,
required = true
allowableValues = {AerospikeAPIConstants.BATCH_TYPE_READ},
requiredMode = Schema.RequiredMode.REQUIRED
)
public final String type = AerospikeAPIConstants.BATCH_TYPE_READ;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,20 @@
import io.swagger.v3.oas.annotations.media.Schema;

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonSubTypes(
{
@JsonSubTypes.Type(value = BatchRead.class, name = AerospikeAPIConstants.BATCH_TYPE_READ),
@JsonSubTypes.Type(
value = BatchWrite.class, name = AerospikeAPIConstants.BATCH_TYPE_WRITE
),
@JsonSubTypes.Type(
value = BatchDelete.class, name = AerospikeAPIConstants.BATCH_TYPE_DELETE
),
@JsonSubTypes.Type(value = BatchUDF.class, name = AerospikeAPIConstants.BATCH_TYPE_UDF),
}
)
@JsonSubTypes({
@JsonSubTypes.Type(value = BatchRead.class, name = AerospikeAPIConstants.BATCH_TYPE_READ),
@JsonSubTypes.Type(value = BatchWrite.class, name = AerospikeAPIConstants.BATCH_TYPE_WRITE),
@JsonSubTypes.Type(value = BatchDelete.class, name = AerospikeAPIConstants.BATCH_TYPE_DELETE),
@JsonSubTypes.Type(value = BatchUDF.class, name = AerospikeAPIConstants.BATCH_TYPE_UDF),
})
@Schema(
description = "The batch operation base type.", oneOf = {
BatchRead.class, BatchWrite.class, BatchDelete.class, BatchUDF.class
}
description = "The batch operation base type.",
oneOf = {BatchRead.class, BatchWrite.class, BatchDelete.class, BatchUDF.class}
)
public abstract class BatchRecord {
@Schema(description = "Key to a record.", required = true)
@Schema(description = "Key to a record.", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty(required = true)
public RestClientKey key;

abstract public com.aerospike.client.BatchRecord toBatchRecord();
public abstract com.aerospike.client.BatchRecord toBatchRecord();
}

Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,25 @@
)
public class BatchRecordResponse {

public BatchRecordResponse() {
}

public BatchRecordResponse(BatchRecord batchRecord) {
resultCode = batchRecord.resultCode;
resultCodeString = ResultCode.getResultString(resultCode);
record = batchRecord.record != null ? new RestClientRecord(batchRecord.record) : null;
key = new RestClientKey(batchRecord.key);
inDoubt = batchRecord.inDoubt;
}

@Schema(description = "Result code for this returned record.")
public int resultCode;

@Schema(description = "Message associated with resultCode.")
public String resultCodeString;

@Schema(description = "Record associated with the key. Null if the record was not found.")
public RestClientRecord record;

@Schema(description = "Key to retrieve a record.")
public RestClientKey key;

@Schema(description = "Is it possible that the write transaction may have completed even though an error occurred for this record.")
public boolean inDoubt;
}

public BatchRecordResponse() {
}

public BatchRecordResponse(BatchRecord batchRecord) {
resultCode = batchRecord.resultCode;
resultCodeString = ResultCode.getResultString(resultCode);
record = batchRecord.record != null ? new RestClientRecord(batchRecord.record) : null;
key = new RestClientKey(batchRecord.key);
inDoubt = batchRecord.inDoubt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public class BatchUDF extends BatchRecord {

@Schema(
description = "List of bins to limit the record response to.",
allowableValues = AerospikeAPIConstants.BATCH_TYPE_UDF,
required = true
allowableValues = {AerospikeAPIConstants.BATCH_TYPE_UDF},
requiredMode = Schema.RequiredMode.REQUIRED
)
@JsonProperty(required = true)
public final String type = AerospikeAPIConstants.BATCH_TYPE_UDF;
Expand Down Expand Up @@ -81,4 +81,3 @@ public com.aerospike.client.BatchUDF toBatchRecord() {
return new com.aerospike.client.BatchUDF(batchUDFPolicy, key.toKey(), packageName, functionName, values);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class BatchWrite extends BatchRecord {

@Schema(
description = "List of bins to limit the record response to.",
allowableValues = AerospikeAPIConstants.BATCH_TYPE_WRITE,
required = true
allowableValues = {AerospikeAPIConstants.BATCH_TYPE_WRITE},
requiredMode = Schema.RequiredMode.REQUIRED
)
@JsonProperty(required = true)
public final String type = AerospikeAPIConstants.BATCH_TYPE_WRITE;
Expand Down
30 changes: 13 additions & 17 deletions src/main/java/com/aerospike/restclient/domain/ctxmodels/CTX.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,17 @@
}
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonSubTypes(
{
@JsonSubTypes.Type(value = ListIndexCTX.class, name = AerospikeAPIConstants.CTX.LIST_INDEX),
@JsonSubTypes.Type(value = ListRankCTX.class, name = AerospikeAPIConstants.CTX.LIST_RANK),
@JsonSubTypes.Type(value = ListValueCTX.class, name = AerospikeAPIConstants.CTX.LIST_VALUE),
@JsonSubTypes.Type(value = MapIndexCTX.class, name = AerospikeAPIConstants.CTX.MAP_INDEX),
@JsonSubTypes.Type(value = MapRankCTX.class, name = AerospikeAPIConstants.CTX.MAP_RANK),
@JsonSubTypes.Type(value = MapKeyCTX.class, name = AerospikeAPIConstants.CTX.MAP_KEY),
@JsonSubTypes.Type(value = MapValueCTX.class, name = AerospikeAPIConstants.CTX.MAP_VALUE),
@JsonSubTypes.Type(value = MapKeyCreateCTX.class, name = AerospikeAPIConstants.CTX.MAP_KEY_CREATE),
@JsonSubTypes.Type(
value = ListIndexCreateCTX.class, name = AerospikeAPIConstants.CTX.LIST_INDEX_CREATE
),
}
)
abstract public class CTX {
abstract public com.aerospike.client.cdt.CTX toCTX();
@JsonSubTypes({
@JsonSubTypes.Type(value = ListIndexCTX.class, name = AerospikeAPIConstants.CTX.LIST_INDEX),
@JsonSubTypes.Type(value = ListRankCTX.class, name = AerospikeAPIConstants.CTX.LIST_RANK),
@JsonSubTypes.Type(value = ListValueCTX.class, name = AerospikeAPIConstants.CTX.LIST_VALUE),
@JsonSubTypes.Type(value = MapIndexCTX.class, name = AerospikeAPIConstants.CTX.MAP_INDEX),
@JsonSubTypes.Type(value = MapRankCTX.class, name = AerospikeAPIConstants.CTX.MAP_RANK),
@JsonSubTypes.Type(value = MapKeyCTX.class, name = AerospikeAPIConstants.CTX.MAP_KEY),
@JsonSubTypes.Type(value = MapValueCTX.class, name = AerospikeAPIConstants.CTX.MAP_VALUE),
@JsonSubTypes.Type(value = MapKeyCreateCTX.class, name = AerospikeAPIConstants.CTX.MAP_KEY_CREATE),
@JsonSubTypes.Type(value = ListIndexCreateCTX.class, name = AerospikeAPIConstants.CTX.LIST_INDEX_CREATE),
})
public abstract class CTX {
public abstract com.aerospike.client.cdt.CTX toCTX();
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
public class ListIndexCTX extends CTX {
@Schema(
description = "The type of context this object represents. It is always " + AerospikeAPIConstants.CTX.LIST_INDEX,
allowableValues = AerospikeAPIConstants.CTX.LIST_INDEX,
required = true
allowableValues = {AerospikeAPIConstants.CTX.LIST_INDEX},
requiredMode = Schema.RequiredMode.REQUIRED
)
public final String type = AerospikeAPIConstants.CTX.LIST_INDEX;

@Schema(
description = "If the index is negative, the resolved index starts backwards from end of list. If an index is out of bounds, a parameter error will be returned. Examples:\n" + "* 0: First item.\n" + "* 4: Fifth item.\n" + "* -1: Last item.\n" + "* -3: Third to last item.",
required = true
requiredMode = Schema.RequiredMode.REQUIRED
)
public Integer index;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
public class ListIndexCreateCTX extends CTX {
@Schema(
description = "The type of context this object represents. It is always " + AerospikeAPIConstants.CTX.LIST_INDEX_CREATE,
allowableValues = AerospikeAPIConstants.CTX.LIST_INDEX_CREATE,
required = true
allowableValues = {AerospikeAPIConstants.CTX.LIST_INDEX_CREATE},
requiredMode = Schema.RequiredMode.REQUIRED
)
public final String type = AerospikeAPIConstants.CTX.LIST_INDEX_CREATE;

@Schema(
description = "If the index is negative, the resolved index starts backwards from end of list. If an index is out of bounds, a parameter error will be returned. Examples:\n" + "* 0: First item.\n" + "* 4: Fifth item.\n" + "* -1: Last item.\n" + "* -3: Third to last item.",
required = true
requiredMode = Schema.RequiredMode.REQUIRED
)
public Integer index;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
public class ListRankCTX extends CTX {
@Schema(
description = "The type of context this object represents. It is always " + AerospikeAPIConstants.CTX.LIST_RANK,
allowableValues = AerospikeAPIConstants.CTX.LIST_RANK,
required = true
allowableValues = {AerospikeAPIConstants.CTX.LIST_RANK},
requiredMode = Schema.RequiredMode.REQUIRED
)
public final String type = AerospikeAPIConstants.CTX.LIST_RANK;

@Schema(
description = """
* 0 = smallest value
* N = Nth smallest value
* -1 = largest value""", required = true
* -1 = largest value""", requiredMode = Schema.RequiredMode.REQUIRED
)
public Integer rank;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
public class ListValueCTX extends CTX {
@Schema(
description = "The type of context this object represents. It is always " + AerospikeAPIConstants.CTX.LIST_VALUE,
allowableValues = AerospikeAPIConstants.CTX.LIST_VALUE,
required = true
allowableValues = {AerospikeAPIConstants.CTX.LIST_VALUE},
requiredMode = Schema.RequiredMode.REQUIRED
)
@JsonProperty(required = true)
public final String type = AerospikeAPIConstants.CTX.LIST_VALUE;

@Schema(required = true)
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
@JsonDeserialize(using = ObjectDeserializer.class)
public Object value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
public class MapIndexCTX extends CTX {
@Schema(
description = "The type of context this object represents. It is always " + AerospikeAPIConstants.CTX.MAP_INDEX,
allowableValues = AerospikeAPIConstants.CTX.MAP_INDEX,
required = true
allowableValues = {AerospikeAPIConstants.CTX.MAP_INDEX},
requiredMode = Schema.RequiredMode.REQUIRED
)
@JsonProperty(required = true)
public final String type = AerospikeAPIConstants.CTX.MAP_INDEX;

@Schema(
description = "If the index is negative, the resolved index starts backwards from end of list. If an index is out of bounds, a parameter error will be returned. Examples:\n" + "\n" + "* 0: First item.\n" + "* 4: Fifth item.\n" + "* -1: Last item.\n" + "* -3: Third to last item.",
required = true
requiredMode = Schema.RequiredMode.REQUIRED
)
@JsonProperty(required = true)
public Integer index;
Expand Down
Loading

0 comments on commit 55d5bd8

Please sign in to comment.