From b18498e942571e4cd673bc81b859a126285118a9 Mon Sep 17 00:00:00 2001 From: Bernd Hufmann Date: Tue, 29 Oct 2024 16:03:15 -0400 Subject: [PATCH] swagger: Fix swagger annotations for global and output configurations The documentation didn't match the implementation. This PR fixes this. Rename the implementation class ConfigurationQueryParameters to InputConfigurationQueryParameters because for some reason it's put into the swagger documentation and before it classed with the swagger doc class for ConfigurationQueryParameters, and hence it was incorrect. Note that InputConfigurationQueryParameters needs to be manually removed from the genereated swagger doc. Signed-off-by: Bernd Hufmann --- .../services/ConfigurationManagerServiceTest.java | 8 ++++---- .../jersey/rest/core/tests/utils/RestServerTest.java | 6 +++--- ...rameters.java => ConfigurationQueryParameters.java} | 2 +- .../core/model/OutputConfigurationQueryParameters.java | 2 +- ...ers.java => InputConfigurationQueryParameters.java} | 6 +++--- .../core/services/ConfigurationManagerService.java | 10 +++++----- .../jersey/rest/core/services/DataProviderService.java | 8 ++++---- 7 files changed, 21 insertions(+), 21 deletions(-) rename trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/{BaseConfigurationQueryParameters.java => ConfigurationQueryParameters.java} (96%) rename trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/{ConfigurationQueryParameters.java => InputConfigurationQueryParameters.java} (92%) diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ConfigurationManagerServiceTest.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ConfigurationManagerServiceTest.java index 9b29ce1f3..dbc9f1f94 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ConfigurationManagerServiceTest.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/ConfigurationManagerServiceTest.java @@ -38,7 +38,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.ConfigurationQueryParameters; +import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.InputConfigurationQueryParameters; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.QueryParameters; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.ConfigurationManagerService; import org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.stubs.ExperimentModelStub; @@ -358,7 +358,7 @@ private static Response createConfig(String path, boolean isCorrectType) { parameters.put(PATH, path); } return endpoint.request(MediaType.APPLICATION_JSON) - .post(Entity.json(new ConfigurationQueryParameters(null, null, null, parameters))); + .post(Entity.json(new InputConfigurationQueryParameters(null, null, null, parameters))); } private static Response createJsonConfig(String jsonFileName) throws URISyntaxException, IOException { @@ -371,7 +371,7 @@ private static Response createJsonConfig(String jsonFileName) throws URISyntaxEx Map params = readParametersFromJson(jsonFileName); return endpoint.request(MediaType.APPLICATION_JSON) - .post(Entity.json(new ConfigurationQueryParameters(null, null, null, params))); + .post(Entity.json(new InputConfigurationQueryParameters(null, null, null, params))); } private static Response updateConfig(String path, String id) { @@ -403,7 +403,7 @@ private static Response updateConfig(String path, String id, boolean isCorrectTy parameters.put(PATH, path); } return endpoint.request(MediaType.APPLICATION_JSON) - .put(Entity.json(new ConfigurationQueryParameters(null, null, null, parameters))); + .put(Entity.json(new InputConfigurationQueryParameters(null, null, null, parameters))); } private static Response deleteConfig(String id) { diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/utils/RestServerTest.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/utils/RestServerTest.java index 94cc41d1b..7d1cdc6d2 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/utils/RestServerTest.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/utils/RestServerTest.java @@ -37,7 +37,7 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; -import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.ConfigurationQueryParameters; +import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.InputConfigurationQueryParameters; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.QueryParameters; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.webapp.TraceServerConfiguration; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.webapp.WebApplication; @@ -627,7 +627,7 @@ public static ExperimentModelStub assertPostExperiment(String name, TraceModelSt @SuppressWarnings("null") public static DataProviderDescriptorStub assertDpPost(WebTarget dpConfigEndpoint, ITmfConfiguration configuration) { try (Response response = dpConfigEndpoint.request().post(Entity.json( - new ConfigurationQueryParameters(configuration.getName(), configuration.getDescription(), configuration.getSourceTypeId(), configuration.getParameters())))) { + new InputConfigurationQueryParameters(configuration.getName(), configuration.getDescription(), configuration.getSourceTypeId(), configuration.getParameters())))) { int code = response.getStatus(); assertEquals("Failed to POST " + configuration.getName() + ", error code=" + code, 200, code); DataProviderDescriptorStub result = response.readEntity(DataProviderDescriptorStub.class); @@ -651,7 +651,7 @@ public static DataProviderDescriptorStub assertDpPost(WebTarget dpConfigEndpoint @SuppressWarnings("null") public static Response assertDpPostWithErrors(WebTarget dpConfigEndpoint, ITmfConfiguration configuration) { return dpConfigEndpoint.request().post(Entity.json( - new ConfigurationQueryParameters(configuration.getName(), configuration.getDescription(), configuration.getSourceTypeId(), configuration.getParameters()))); + new InputConfigurationQueryParameters(configuration.getName(), configuration.getDescription(), configuration.getSourceTypeId(), configuration.getParameters()))); } /** diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/BaseConfigurationQueryParameters.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/ConfigurationQueryParameters.java similarity index 96% rename from trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/BaseConfigurationQueryParameters.java rename to trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/ConfigurationQueryParameters.java index 026a53da0..11a0946f7 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/BaseConfigurationQueryParameters.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/ConfigurationQueryParameters.java @@ -18,7 +18,7 @@ /** * Contributes to the model used for TSP swagger-core annotations. */ -public interface BaseConfigurationQueryParameters { +public interface ConfigurationQueryParameters { /** * @return the name of the configuration */ diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/OutputConfigurationQueryParameters.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/OutputConfigurationQueryParameters.java index 395ba5647..caf6561f9 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/OutputConfigurationQueryParameters.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/OutputConfigurationQueryParameters.java @@ -18,7 +18,7 @@ /** * Contributes to the model used for TSP swagger-core annotations. */ -public interface OutputConfigurationQueryParameters extends BaseConfigurationQueryParameters { +public interface OutputConfigurationQueryParameters extends ConfigurationQueryParameters { /** * @return the typeId of the configuration according to the * {@link ConfigurationSourceType} diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/ConfigurationQueryParameters.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/InputConfigurationQueryParameters.java similarity index 92% rename from trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/ConfigurationQueryParameters.java rename to trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/InputConfigurationQueryParameters.java index 78b208c13..09873e170 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/ConfigurationQueryParameters.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/views/InputConfigurationQueryParameters.java @@ -20,7 +20,7 @@ /** * Definition of a parameters object received by the server from a client for configurations. */ -public class ConfigurationQueryParameters { +public class InputConfigurationQueryParameters { private @NonNull String name; private @NonNull String description; private @NonNull String typeId; @@ -29,7 +29,7 @@ public class ConfigurationQueryParameters { /** * Constructor for Jackson */ - public ConfigurationQueryParameters() { + public InputConfigurationQueryParameters() { // Default constructor for Jackson this.parameters = new HashMap<>(); @@ -51,7 +51,7 @@ public ConfigurationQueryParameters() { * @param parameters * Map of parameters */ - public ConfigurationQueryParameters(String name, String description, String typeId, Map parameters) { + public InputConfigurationQueryParameters(String name, String description, String typeId, Map parameters) { this.parameters = parameters != null ? parameters : new HashMap<>(); this.name = name == null ? TmfConfiguration.UNKNOWN : name; this.description = description == null ? TmfConfiguration.UNKNOWN : description; diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/ConfigurationManagerService.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/ConfigurationManagerService.java index 77e741c86..4cf2c4d9c 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/ConfigurationManagerService.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/ConfigurationManagerService.java @@ -31,7 +31,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; -import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.ConfigurationQueryParameters; +import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.InputConfigurationQueryParameters; import org.eclipse.tracecompass.tmf.core.config.ITmfConfiguration; import org.eclipse.tracecompass.tmf.core.config.ITmfConfigurationSource; import org.eclipse.tracecompass.tmf.core.config.TmfConfiguration; @@ -143,8 +143,8 @@ public Response getConfigurations(@Parameter(description = CFG_TYPE_ID) @PathPar public Response postConfiguration(@Parameter(description = CFG_TYPE_ID) @PathParam("typeId") String typeId, @RequestBody(description = CFG_CREATE_DESC + " " + CFG_KEYS_DESC, content = { @Content(examples = @ExampleObject("{\"parameters\":{" + CFG_PATH_EX + - "}}"), schema = @Schema(implementation = org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.BaseConfigurationQueryParameters.class)) - }, required = true) ConfigurationQueryParameters queryParameters) { + "}}"), schema = @Schema(implementation = org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.ConfigurationQueryParameters.class)) + }, required = true) InputConfigurationQueryParameters queryParameters) { ITmfConfigurationSource configurationSource = fConfigSourceManager.getConfigurationSource(typeId); if (configurationSource == null) { return Response.status(Status.NOT_FOUND).entity("Configuration source type doesn't exist").build(); //$NON-NLS-1$ @@ -224,8 +224,8 @@ public Response putConfiguration(@Parameter(description = CFG_TYPE_ID) @PathPara @Parameter(description = CFG_CONFIG_ID) @PathParam("configId") String configId, @RequestBody(description = CFG_UPDATE_DESC + " " + CFG_KEYS_DESC, content = { @Content(examples = @ExampleObject("{\"parameters\":{" + CFG_PATH_EX + - "}}"), schema = @Schema(implementation = org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.BaseConfigurationQueryParameters.class)) - }, required = true) ConfigurationQueryParameters queryParameters) { + "}}"), schema = @Schema(implementation = org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.ConfigurationQueryParameters.class)) + }, required = true) InputConfigurationQueryParameters queryParameters) { ITmfConfigurationSource configurationSource = fConfigSourceManager.getConfigurationSource(typeId); if (configurationSource == null) { return Response.status(Status.NOT_FOUND).entity("Configuration source type doesn't exist").build(); //$NON-NLS-1$ diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java index 8d3d076f8..b2ff4823a 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/DataProviderService.java @@ -123,7 +123,7 @@ import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.VirtualTableResponse; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.XYResponse; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.XYTreeResponse; -import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.ConfigurationQueryParameters; +import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.InputConfigurationQueryParameters; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.GenericView; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.QueryParameters; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.TableColumnHeader; @@ -1256,7 +1256,7 @@ public Response getConfigurationType( @Tag(name = OCG) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @Operation(summary = "Get the list of outputs for this configuration", responses = { + @Operation(summary = "Get a derived data provider from a input configuration", responses = { @ApiResponse(responseCode = "200", description = "Returns a list of output provider descriptors", content = @Content(array = @ArraySchema(schema = @Schema(implementation = DataProvider.class)))), @ApiResponse(responseCode = "400", description = INVALID_PARAMETERS, content = @Content(schema = @Schema(implementation = String.class))), @ApiResponse(responseCode = "404", description = PROVIDER_CONFIG_NOT_FOUND, content = @Content(schema = @Schema(implementation = String.class))), @@ -1266,7 +1266,7 @@ public Response createDataProvider( @Parameter(description = OUTPUT_ID) @PathParam("outputId") String outputId, @RequestBody(description = CFG_CREATE_DESC + " " + CFG_KEYS_DESC, content = { @Content(schema = @Schema(implementation = org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.OutputConfigurationQueryParameters.class)) - }, required = true) ConfigurationQueryParameters queryParameters) { + }, required = true) InputConfigurationQueryParameters queryParameters) { try (FlowScopeLog scope = new FlowScopeLogBuilder(LOGGER, Level.FINE, "DataProviderService#createDataProvider") //$NON-NLS-1$ .setCategory(outputId).build()) { @@ -1384,7 +1384,7 @@ private static Response validateParameters(String outputId, QueryParameters quer return null; } - private static Response validateOutputConfigParameters(String outputId, ConfigurationQueryParameters queryParameters) { + private static Response validateOutputConfigParameters(String outputId, InputConfigurationQueryParameters queryParameters) { if (outputId == null) { return Response.status(Status.BAD_REQUEST).entity(MISSING_OUTPUTID).build(); }