Skip to content

Commit

Permalink
swagger: Fix swagger annotations for global and output configurations
Browse files Browse the repository at this point in the history
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 <bernd.hufmann@ericsson.com>
  • Loading branch information
bhufmann committed Oct 29, 2024
1 parent 1e41138 commit b18498e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -371,7 +371,7 @@ private static Response createJsonConfig(String jsonFileName) throws URISyntaxEx

Map<String, Object> 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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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())));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,7 +29,7 @@ public class ConfigurationQueryParameters {
/**
* Constructor for Jackson
*/
public ConfigurationQueryParameters() {
public InputConfigurationQueryParameters() {

// Default constructor for Jackson
this.parameters = new HashMap<>();
Expand All @@ -51,7 +51,7 @@ public ConfigurationQueryParameters() {
* @param parameters
* Map of parameters
*/
public ConfigurationQueryParameters(String name, String description, String typeId, Map<String, Object> parameters) {
public InputConfigurationQueryParameters(String name, String description, String typeId, Map<String, Object> parameters) {
this.parameters = parameters != null ? parameters : new HashMap<>();
this.name = name == null ? TmfConfiguration.UNKNOWN : name;
this.description = description == null ? TmfConfiguration.UNKNOWN : description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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$
Expand Down Expand Up @@ -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$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))),
Expand All @@ -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()) {
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit b18498e

Please sign in to comment.