From cdfc58adc66b77b9b2837c7b3acae7b228de5ec7 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Mon, 14 Jul 2025 20:40:18 -0500 Subject: [PATCH] Replaced deprecated withIn and withType methods that took strings in favor of ones that take enum constants --- .../actions/GenerateOpenApiSpecAction.java | 124 +++++++++--------- ...derSavedReportProcessApiProcessOutput.java | 7 +- .../processes/ApiProcessObjectOutput.java | 3 +- .../ApiProcessSummaryListOutput.java | 13 +- 4 files changed, 76 insertions(+), 71 deletions(-) diff --git a/qqq-middleware-api/src/main/java/com/kingsrook/qqq/api/actions/GenerateOpenApiSpecAction.java b/qqq-middleware-api/src/main/java/com/kingsrook/qqq/api/actions/GenerateOpenApiSpecAction.java index c6eda4c5..8bd87a45 100644 --- a/qqq-middleware-api/src/main/java/com/kingsrook/qqq/api/actions/GenerateOpenApiSpecAction.java +++ b/qqq-middleware-api/src/main/java/com/kingsrook/qqq/api/actions/GenerateOpenApiSpecAction.java @@ -83,6 +83,7 @@ import com.kingsrook.qqq.openapi.model.Content; import com.kingsrook.qqq.openapi.model.Example; import com.kingsrook.qqq.openapi.model.ExampleWithListValue; import com.kingsrook.qqq.openapi.model.ExampleWithSingleValue; +import com.kingsrook.qqq.openapi.model.In; import com.kingsrook.qqq.openapi.model.Info; import com.kingsrook.qqq.openapi.model.Method; import com.kingsrook.qqq.openapi.model.OpenAPI; @@ -93,6 +94,7 @@ import com.kingsrook.qqq.openapi.model.Response; import com.kingsrook.qqq.openapi.model.Schema; import com.kingsrook.qqq.openapi.model.SecurityScheme; import com.kingsrook.qqq.openapi.model.Tag; +import com.kingsrook.qqq.openapi.model.Type; import io.javalin.http.ContentType; import io.javalin.http.HttpStatus; import org.apache.commons.lang.BooleanUtils; @@ -289,16 +291,16 @@ public class GenerateOpenApiSpecAction extends AbstractQActionFunction tableFields = new LinkedHashMap<>(); Schema tableSchema = new Schema() - .withType("object") + .withType(Type.OBJECT) .withProperties(tableFields); for(QFieldMetaData field : tableApiFields) @@ -1461,7 +1463,7 @@ public class GenerateOpenApiSpecAction extends AbstractQActionFunction properties = new LinkedHashMap<>(); - properties.put("statusCode", new Schema().withType("integer")); - properties.put("statusText", new Schema().withType("string")); - properties.put("error", new Schema().withType("string")); + properties.put("statusCode", new Schema().withType(Type.INTEGER)); + properties.put("statusText", new Schema().withType(Type.STRING)); + properties.put("error", new Schema().withType(Type.STRING)); properties.put(primaryKeyApiName, new Schema().withType(getFieldType(primaryKeyField))); return new Response() .withDescription("Multiple statuses. See body for details.") .withContent(MapBuilder.of("application/json", new Content() .withSchema(new Schema() - .withType("array") + .withType(Type.ARRAY) .withItems(new Schema() - .withType("object") + .withType(Type.OBJECT) .withProperties(properties)) .withExample(example)))); } @@ -1704,7 +1706,7 @@ public class GenerateOpenApiSpecAction extends AbstractQActionFunction "string"; - case INTEGER, LONG -> "integer"; // todo - we could give 'format' w/ int32 & int64 to further specify - case DECIMAL -> "number"; - case BOOLEAN -> "boolean"; + case STRING, DATE, TIME, DATE_TIME, TEXT, HTML, PASSWORD, BLOB -> Type.STRING; + case INTEGER, LONG -> Type.INTEGER; // todo - we could give 'format' w/ int32 & int64 to further specify + case DECIMAL -> Type.NUMBER; + case BOOLEAN -> Type.BOOLEAN; }; } @@ -1796,9 +1798,9 @@ public class GenerateOpenApiSpecAction extends AbstractQActionFunction getSpecResponses(String apiName) { Map propertiesFor207Object = new LinkedHashMap<>(); - propertiesFor207Object.put("id", new Schema().withType("integer").withDescription("Id of the record whose status is being described in the object")); - propertiesFor207Object.put("statusCode", new Schema().withType("integer").withDescription("HTTP Status code indicating the success or failure of the process on this record")); - propertiesFor207Object.put("statusText", new Schema().withType("string").withDescription("HTTP Status text indicating the success or failure of the process on this record")); - propertiesFor207Object.put("message", new Schema().withType("string").withDescription("Additional descriptive information about the result of the process on this record.")); + propertiesFor207Object.put("id", new Schema().withType(Type.INTEGER).withDescription("Id of the record whose status is being described in the object")); + propertiesFor207Object.put("statusCode", new Schema().withType(Type.INTEGER).withDescription("HTTP Status code indicating the success or failure of the process on this record")); + propertiesFor207Object.put("statusText", new Schema().withType(Type.STRING).withDescription("HTTP Status text indicating the success or failure of the process on this record")); + propertiesFor207Object.put("message", new Schema().withType(Type.STRING).withDescription("Additional descriptive information about the result of the process on this record.")); List exampleFor207Object = ListBuilder.of(MapBuilder.of(LinkedHashMap::new) .with("id", 42) @@ -112,9 +113,9 @@ public class ApiProcessSummaryListOutput implements ApiProcessOutputInterface .withDescription("For each input record, an object describing its status may be returned.") .withContent(MapBuilder.of(ContentType.JSON, new Content() .withSchema(new Schema() - .withType("array") + .withType(Type.ARRAY) .withItems(new Schema() - .withType("object") + .withType(Type.OBJECT) .withProperties(propertiesFor207Object)) .withExample(exampleFor207Object) )