diff --git a/hawkbit-ddi/hawkbit-ddi-server/src/main/resources/application.properties b/hawkbit-ddi/hawkbit-ddi-server/src/main/resources/application.properties index cafe30143..bb50ac518 100644 --- a/hawkbit-ddi/hawkbit-ddi-server/src/main/resources/application.properties +++ b/hawkbit-ddi/hawkbit-ddi-server/src/main/resources/application.properties @@ -49,13 +49,6 @@ spring.rabbitmq.port=5672 #hawkbit.server.security.cors.enabled=true #hawkbit.server.security.cors.allowedOrigins=http://localhost -# Swagger Configuration -springdoc.api-docs.version=openapi_3_0 -springdoc.show-oauth2-endpoints=true -springdoc.show-login-endpoint=true -springdoc.packages-to-scan=org.eclipse.hawkbit.ddi -springdoc.paths-to-exclude=/system/** - ## No Schedulers - START hawkbit.autoassign.scheduler.enabled=false hawkbit.rollout.scheduler.enabled=false @@ -76,4 +69,14 @@ spring.cloud.stream.bindings.springCloudBusInput.group=ddi-server # To use protostuff (for instance fot improved performance) you shall uncomment # the following two lines and add io.protostuff:protostuff-core and io.protostuff:protostuff-runtime to dependencies #spring.cloud.stream.bindings.springCloudBusInput.content-type=application/binary+protostuff -#spring.cloud.stream.bindings.springCloudBusOutput.content-type=application/binary+protostuff \ No newline at end of file +#spring.cloud.stream.bindings.springCloudBusOutput.content-type=application/binary+protostuff + +# Swagger Configuration / https://springdoc.org/v2/#properties +springdoc.api-docs.version=openapi_3_0 +springdoc.show-oauth2-endpoints=true +springdoc.show-login-endpoint=true +springdoc.packages-to-scan=org.eclipse.hawkbit.ddi +springdoc.paths-to-exclude=/system/** +springdoc.swagger-ui.enabled=true +springdoc.swagger-ui.csrf.enabled=true +springdoc.swagger-ui.doc-expansion=none \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java index 2c8cc2bb1..1ee644e83 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java @@ -9,7 +9,11 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.ACTION_ORDER; + import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -17,6 +21,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import org.eclipse.hawkbit.mgmt.json.model.PagedList; import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; @@ -29,7 +34,9 @@ import org.springframework.web.bind.annotation.RequestParam; * REST API providing (read-only) access to actions. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "Actions", description = "REST API providing (read-only) access to actions.") +@Tag( + name = "Actions", description = "REST API providing (read-only) access to actions.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = ACTION_ORDER))) public interface MgmtActionRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java index 1737d32b4..74c423b23 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java @@ -9,8 +9,13 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.BASIC_AUTH_ORDER; + +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.tags.Tag; import org.eclipse.hawkbit.mgmt.json.model.auth.MgmtUserInfo; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -20,7 +25,9 @@ import org.springframework.web.bind.annotation.GetMapping; * Api for handling basic auth user validation */ @SuppressWarnings("squid:S1609") -@Tag(name = "Basic Authentication", description = "API for basic auth user validation.") +@Tag( + name = "Basic Authentication", description = "API for basic auth user validation.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = BASIC_AUTH_ORDER))) // no request mapping specified here to avoid CVE-2021-22044 in Feign client public interface MgmtBasicAuthRestApi { @@ -31,4 +38,4 @@ public interface MgmtBasicAuthRestApi { */ @GetMapping(value = MgmtRestConstants.AUTH_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity validateBasicAuth(); -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java index 445bebcb1..631b54e09 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java @@ -9,11 +9,15 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.DISTRIBUTION_SET_ORDER; + import java.util.List; import jakarta.validation.Valid; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -33,6 +37,7 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssignment; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQuery; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.HttpStatus; @@ -51,7 +56,9 @@ import org.springframework.web.bind.annotation.ResponseStatus; * REST Resource handling for DistributionSet CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "Distribution Sets", description = "REST Resource handling for DistributionSet CRUD operations.") +@Tag( + name = "Distribution Sets", description = "REST Resource handling for DistributionSet CRUD operations.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = DISTRIBUTION_SET_ORDER))) public interface MgmtDistributionSetRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java index ffb532cd5..62ff3cf0b 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java @@ -9,9 +9,13 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.DISTRIBUTION_SET_TAG_ORDER; + import java.util.List; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -21,6 +25,7 @@ import org.eclipse.hawkbit.mgmt.json.model.PagedList; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag; import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; @@ -37,7 +42,9 @@ import org.springframework.web.bind.annotation.RequestParam; * REST Resource handling for DistributionSetTag CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "Distribution Set Tags", description = "REST Resource handling for DistributionSetTag CRUD operations.") +@Tag( + name = "Distribution Set Tags", description = "REST Resource handling for DistributionSetTag CRUD operations.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = DISTRIBUTION_SET_TAG_ORDER))) public interface MgmtDistributionSetTagRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java index b83f4d4c7..547ac7527 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java @@ -9,9 +9,13 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.DISTRIBUTION_SET_TYPE_ORDER; + import java.util.List; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -23,6 +27,7 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionS import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPut; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; @@ -39,7 +44,9 @@ import org.springframework.web.bind.annotation.RequestParam; * REST Resource handling for DistributionSetType CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "Distribution Set Types", description = "REST Resource handling for DistributionSetType CRUD operations.") +@Tag( + name = "Distribution Set Types", description = "REST Resource handling for DistributionSetType CRUD operations.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = DISTRIBUTION_SET_TYPE_ORDER))) public interface MgmtDistributionSetTypeRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java index 5b3151f49..a788773c8 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java @@ -9,9 +9,14 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.DOWNLOAD_ARTIFACT_ORDER; + import java.io.InputStream; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.tags.Tag; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -21,7 +26,9 @@ import org.springframework.web.bind.annotation.ResponseBody; * API to download artifacts */ @FunctionalInterface -@Tag(name = "Download artifact", description = "API to download artifacts.") +@Tag( + name = "Download artifact", description = "API to download artifacts.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = DOWNLOAD_ARTIFACT_ORDER))) // no request mapping specified here to avoid CVE-2021-22044 in Feign client public interface MgmtDownloadArtifactRestApi { diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java index 8d21f5e70..b877a15e4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java @@ -227,4 +227,20 @@ public final class MgmtRestConstants { * Request parameter if the artifact url handler should be used */ public static final String REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER = "useartifacturlhandler"; + + // Orders + public static final String TARGET_ORDER = "1000"; + public static final String TARGET_TAG_ORDER = "2000"; + public static final String TARGET_TYPE_ORDER = "3000"; + public static final String TARGET_FILTER_ORDER = "4000"; + public static final String ACTION_ORDER = "5000"; + public static final String ROLLOUT_ORDER = "6000"; + public static final String DISTRIBUTION_SET_ORDER = "7000"; + public static final String DISTRIBUTION_SET_TYPE_ORDER = "8000"; + public static final String DISTRIBUTION_SET_TAG_ORDER = "9000"; + public static final String SOFTWARE_MODULE_ORDER = "10000"; + public static final String SOFTWARE_MODULE_TYPE_ORDER = "11000"; + public static final String TENANT_ORDER = "100000"; + public static final String BASIC_AUTH_ORDER = "200000"; + public static final String DOWNLOAD_ARTIFACT_ORDER = "1000000"; } diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java index 377eedebf..527ed12e5 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java @@ -9,7 +9,11 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.ROLLOUT_ORDER; + import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -21,6 +25,7 @@ import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutRestRequestBodyPos import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutRestRequestBodyPut; import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroupResponseBody; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; @@ -37,7 +42,9 @@ import org.springframework.web.bind.annotation.RequestParam; * REST Resource handling rollout CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "Rollouts", description = "REST API for Rollout CRUD operations.") +@Tag( + name = "Rollouts", description = "REST API for Rollout CRUD operations.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = ROLLOUT_ORDER))) public interface MgmtRolloutRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java index 21903fe48..93b755456 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java @@ -9,9 +9,13 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.SOFTWARE_MODULE_ORDER; + import java.util.List; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -24,6 +28,7 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleMeta import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleMetadataBodyPut; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPut; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.HttpStatus; @@ -46,7 +51,9 @@ import org.springframework.web.multipart.MultipartFile; * operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "Software Modules", description = "REST API for SoftwareModule and related Artifact CRUD operations.") +@Tag( + name = "Software Modules", description = "REST API for SoftwareModule and related Artifact CRUD operations.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = SOFTWARE_MODULE_ORDER))) public interface MgmtSoftwareModuleRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java index 531db7bb8..95020ce7b 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java @@ -9,9 +9,13 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.SOFTWARE_MODULE_TYPE_ORDER; + import java.util.List; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -21,6 +25,7 @@ import org.eclipse.hawkbit.mgmt.json.model.PagedList; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPut; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; @@ -38,7 +43,9 @@ import org.springframework.web.bind.annotation.RequestParam; * operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "Software Module Types", description = "REST API for SoftwareModuleTypes CRUD operations.") +@Tag( + name = "Software Module Types", description = "REST API for SoftwareModuleTypes CRUD operations.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = SOFTWARE_MODULE_TYPE_ORDER))) public interface MgmtSoftwareModuleTypeRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java index 2bb7a5cf8..279408c21 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java @@ -9,7 +9,11 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_FILTER_ORDER; + import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -20,6 +24,7 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtDistributionSetAutoAssignment; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQuery; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQueryRequestBody; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; @@ -36,7 +41,9 @@ import org.springframework.web.bind.annotation.RequestParam; * Api for handling target operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "Target Filter Queries", description = "REST API for Target Filter Queries CRUD operations.") +@Tag( + name = "Target Filter Queries", description = "REST API for Target Filter Queries CRUD operations.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = TARGET_FILTER_ORDER))) public interface MgmtTargetFilterQueryRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java index 131549f90..79023ff87 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java @@ -9,11 +9,15 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_ORDER; + import java.util.List; import jakarta.validation.Valid; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -36,6 +40,7 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAttributes; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirm; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirmUpdate; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.HttpStatus; @@ -54,7 +59,9 @@ import org.springframework.web.bind.annotation.ResponseStatus; * API for handling target operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "Targets", description = "REST API for Target CRUD operations.") +@Tag( + name = "Targets", description = "REST API for Target CRUD operations.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = TARGET_ORDER))) public interface MgmtTargetRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java index d64ab8f42..f4646c370 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java @@ -9,9 +9,13 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_TAG_ORDER; + import java.util.List; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -21,6 +25,7 @@ import org.eclipse.hawkbit.mgmt.json.model.PagedList; import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag; import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; @@ -37,7 +42,9 @@ import org.springframework.web.bind.annotation.RequestParam; * REST Resource handling for TargetTag CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "Target Tags", description = "REST API for Target Tag CRUD operations.") +@Tag( + name = "Target Tags", description = "REST API for Target Tag CRUD operations.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = TARGET_TAG_ORDER))) public interface MgmtTargetTagRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java index b73df1303..8d214b112 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java @@ -9,9 +9,13 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_TYPE_ORDER; + import java.util.List; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -23,6 +27,7 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionS import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetType; import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetTypeRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetTypeRequestBodyPut; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; @@ -39,7 +44,9 @@ import org.springframework.web.bind.annotation.RequestParam; * REST Resource handling for TargetType CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "Target Types", description = "REST API for Target Type CRUD operations.") +@Tag( + name = "Target Types", description = "REST API for Target Type CRUD operations.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = TARGET_TYPE_ORDER))) public interface MgmtTargetTypeRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java index 49ba53ee6..49eb9e2cb 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java @@ -9,11 +9,15 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TENANT_ORDER; + import java.io.Serializable; import java.util.List; import java.util.Map; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -21,6 +25,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValue; import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValueRequest; +import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.springframework.hateoas.MediaTypes; import org.springframework.http.MediaType; @@ -35,7 +40,9 @@ import org.springframework.web.bind.annotation.RequestBody; * REST Resource for handling tenant specific configuration operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag(name = "System Configuration", description = "REST API for handling tenant specific configuration operations.") +@Tag( + name = "System Configuration", description = "REST API for handling tenant specific configuration operations.", + extensions = @Extension(name = OpenApiConfiguration.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = TENANT_ORDER))) public interface MgmtTenantManagementRestApi { /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/sdfs.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/sdfs.java deleted file mode 100644 index 93db7cb2c..000000000 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/sdfs.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.mgmt; - -public class sdfs { -} diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtOpenApiConfiguration.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtOpenApiConfiguration.java index a93637676..996f14faa 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtOpenApiConfiguration.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtOpenApiConfiguration.java @@ -9,11 +9,17 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import java.util.List; + import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; +import io.swagger.v3.oas.models.servers.ServerVariable; +import io.swagger.v3.oas.models.servers.ServerVariables; import org.eclipse.hawkbit.rest.OpenApiConfiguration; import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -30,11 +36,11 @@ public class MgmtOpenApiConfiguration { value = "hawkbit.server.openapi.mgmt.enabled", havingValue = "true", matchIfMissing = true) - public GroupedOpenApi mgmtApi() { + public GroupedOpenApi mgmtApi(@Value("${hawkbit.server.openapi.mgmt.tenant-endpoint.enabled:false}") final boolean tenantEndpointEnabled) { return GroupedOpenApi .builder() .group("Management API") - .pathsToMatch("/rest/v*/**", "/{tenant}/rest/v*/**") + .pathsToMatch(tenantEndpointEnabled ? new String[] { "/rest/v*/**", "/{tenant}/rest/v*/**" } : new String[] { "/rest/v*/**" }) .addOpenApiCustomizer(openApi -> openApi .info(new Info() @@ -43,6 +49,13 @@ public class MgmtOpenApiConfiguration { The Management API provides access to the management features of the hawkBit. It allows for managing devices, deployments, and other. """)) + .servers(tenantEndpointEnabled + ? List.of( + new Server() + .url("/{tenant}/") + .variables(new ServerVariables().addServerVariable("tenant", tenantSeverVariable())), + new Server().url("/")) + : List.of(new Server().url("/"))) .addSecurityItem(new SecurityRequirement() .addList(BASIC_AUTH_SEC_SCHEME_NAME) .addList(BEARER_AUTH_SEC_SCHEME_NAME)) @@ -52,14 +65,16 @@ public class MgmtOpenApiConfiguration { .addSecuritySchemes(BASIC_AUTH_SEC_SCHEME_NAME, new SecurityScheme() .name(BASIC_AUTH_SEC_SCHEME_NAME) - .description(BASIC_AUTH_SEC_SCHEME_NAME + " Authentication") + .description( + BASIC_AUTH_SEC_SCHEME_NAME + " Authentication") .type(SecurityScheme.Type.HTTP) .in(SecurityScheme.In.HEADER) .scheme("basic")) .addSecuritySchemes(BEARER_AUTH_SEC_SCHEME_NAME, new SecurityScheme() .name(BEARER_AUTH_SEC_SCHEME_NAME) - .description(BEARER_AUTH_SEC_SCHEME_NAME + " Authentication") + .description( + BEARER_AUTH_SEC_SCHEME_NAME + " Authentication") .type(SecurityScheme.Type.HTTP) .in(SecurityScheme.In.HEADER) .bearerFormat("JWT") @@ -67,4 +82,11 @@ public class MgmtOpenApiConfiguration { .tags(OpenApiConfiguration.sort(openApi.getTags()))) .build(); } + + private static ServerVariable tenantSeverVariable() { + final ServerVariable tenantServerVariable = new ServerVariable(); + tenantServerVariable.setDescription("Tenant identifier"); + tenantServerVariable.setDefault("DEFAULT"); + return tenantServerVariable; + } } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-server/src/main/resources/application.properties b/hawkbit-mgmt/hawkbit-mgmt-server/src/main/resources/application.properties index d9bf327ac..d71ed5ab3 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-server/src/main/resources/application.properties +++ b/hawkbit-mgmt/hawkbit-mgmt-server/src/main/resources/application.properties @@ -48,13 +48,6 @@ spring.rabbitmq.port=5672 #hawkbit.server.security.cors.enabled=true #hawkbit.server.security.cors.allowedOrigins=http://localhost -# Swagger Configuration -springdoc.api-docs.version=openapi_3_0 -springdoc.show-oauth2-endpoints=true -springdoc.show-login-endpoint=true -springdoc.packages-to-scan=org.eclipse.hawkbit.mgmt -springdoc.paths-to-exclude=/system/** - # Disable discovery client of spring-cloud-commons spring.cloud.discovery.enabled=false # Enable communication between services @@ -69,4 +62,14 @@ spring.cloud.stream.bindings.springCloudBusInput.group=mgmt-server # To use protostuff (for instance fot improved performance) you shall uncomment # the following two lines and add io.protostuff:protostuff-core and io.protostuff:protostuff-runtime to dependencies #spring.cloud.stream.bindings.springCloudBusInput.content-type=application/binary+protostuff -#spring.cloud.stream.bindings.springCloudBusOutput.content-type=application/binary+protostuff \ No newline at end of file +#spring.cloud.stream.bindings.springCloudBusOutput.content-type=application/binary+protostuff + +# Swagger Configuration / https://springdoc.org/v2/#properties +springdoc.api-docs.version=openapi_3_0 +springdoc.show-oauth2-endpoints=true +springdoc.show-login-endpoint=true +springdoc.packages-to-scan=org.eclipse.hawkbit.mgmt +springdoc.paths-to-exclude=/system/** +springdoc.swagger-ui.enabled=true +springdoc.swagger-ui.csrf.enabled=true +springdoc.swagger-ui.doc-expansion=none \ No newline at end of file diff --git a/hawkbit-monolith/hawkbit-update-server/src/main/resources/application.properties b/hawkbit-monolith/hawkbit-update-server/src/main/resources/application.properties index bd714bc6a..fe9431aec 100644 --- a/hawkbit-monolith/hawkbit-update-server/src/main/resources/application.properties +++ b/hawkbit-monolith/hawkbit-update-server/src/main/resources/application.properties @@ -56,9 +56,12 @@ spring.rabbitmq.port=5672 #hawkbit.server.security.cors.enabled=true #hawkbit.server.security.cors.allowedOrigins=http://localhost -# Swagger Configuration +# Swagger Configuration / https://springdoc.org/v2/#properties springdoc.api-docs.version=openapi_3_0 springdoc.show-oauth2-endpoints=true springdoc.show-login-endpoint=true springdoc.packages-to-scan=org.eclipse.hawkbit.mgmt,org.eclipse.hawkbit.ddi -springdoc.paths-to-exclude=/system/** \ No newline at end of file +springdoc.paths-to-exclude=/system/** +springdoc.swagger-ui.enabled=true +springdoc.swagger-ui.csrf.enabled=true +springdoc.swagger-ui.doc-expansion=none \ No newline at end of file