Skip to content

Uplift swagger to 3.0.0 #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:

# Generating test coverage report and publishing to Codacy
- name: Run report coverage
if: github.event_name == 'push'
uses: codacy/codacy-coverage-reporter-action@v1.3.0
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
Expand Down
13 changes: 3 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,18 +292,11 @@
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
<scope>compile</scope>
</dependency>


<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>

Expand Down
38 changes: 35 additions & 3 deletions src/main/java/com/ericsson/ei/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import springfox.documentation.swagger.web.DocExpansion;
import springfox.documentation.swagger.web.ModelRendering;
import springfox.documentation.swagger.web.OperationsSorter;
import springfox.documentation.swagger.web.TagsSorter;
import springfox.documentation.swagger.web.UiConfiguration;
import springfox.documentation.swagger.web.UiConfigurationBuilder;

import java.util.Collections;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

private static final String CONTACT_NAME = "Eiffel Intelligence Maintainers";
Expand All @@ -51,6 +58,30 @@ public Docket api() {
.apiInfo(metaData());
}

/**
* SwaggerUI information
*/

@Bean
UiConfiguration uiConfig() {
return UiConfigurationBuilder.builder()
.deepLinking(true)
.displayOperationId(false)
.defaultModelsExpandDepth(-1)
.defaultModelExpandDepth(1)
.defaultModelRendering(ModelRendering.EXAMPLE)
.displayRequestDuration(false)
.docExpansion(DocExpansion.NONE)
.filter(false)
.maxDisplayedTags(null)
.operationsSorter(OperationsSorter.ALPHA)
.showExtensions(false)
.tagsSorter(TagsSorter.ALPHA)
.supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS)
.validatorUrl(null)
.build();
}

private ApiInfo metaData() {
ApiInfo apiInfo = new ApiInfo(
"Eiffel Intelligence REST API",
Expand All @@ -59,7 +90,8 @@ private ApiInfo metaData() {
"Terms of service",
new Contact(CONTACT_NAME, CONTACT_URL, CONTACT_EMAIL),
"Apache License Version 2.0",
"https://www.apache.org/licenses/LICENSE-2.0");
"https://www.apache.org/licenses/LICENSE-2.0",
Collections.emptyList());
return apiInfo;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;

/**
* This class represents the REST GET mechanism to extract the aggregated data on the basis of the
* Id from the aggregatedObject.
*/
@Component
@CrossOrigin
@Api(tags = {"Aggregated objects"}, description = "Fetch aggregated data based on Id")
public class AggregatedObjectControllerImpl implements AggregatedObjectController {

private static final Logger LOGGER = LoggerFactory.getLogger(AggregatedObjectControllerImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
import com.ericsson.ei.utils.ResponseMessage;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;

/**
* Endpoint /authentication/login should be secured if LDAP is enabled.
* Endpoint /authentication should never be secured.
*/
@Component
@CrossOrigin
@Api(tags = {"Authentication"}, description = "Authentication queries")
public class AuthenticationControllerImpl implements AuthenticationController {

private static final Logger LOGGER = LoggerFactory.getLogger(AuthenticationControllerImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.ericsson.ei.controller;

import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand All @@ -27,11 +28,12 @@
*
*/
@Controller
@ApiIgnore
public class EIHomeController {

@ApiOperation(value="", hidden = true)
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home() {
return "redirect:/swagger-ui.html";
return "redirect:/swagger-ui/index.html";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
import com.ericsson.ei.utils.ResponseMessage;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;

/**
* This class contains logic for retrieving failed notifications for the given subscription.
*/
@Component
@CrossOrigin
@Api(tags = {"Failed notifications"}, description = "Fetch failed notifications of a subscription")
public class FailedNotificationControllerImpl implements FailedNotificationController {

private final static Logger LOGGER = LoggerFactory.getLogger(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.ericsson.ei.utils.ResponseMessage;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;

import javax.servlet.http.HttpServletRequest;

Expand All @@ -30,6 +31,7 @@

@Component
@CrossOrigin
@Api(tags = {"Information"}, description = "Information about Eiffel Intelligence backend")
public class InformationControllerImpl implements InformationController {
private static final Logger LOGGER = LoggerFactory.getLogger(InformationControllerImpl.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;

@Component
@CrossOrigin
@Api(tags = {"Rules"}, description = "Active rules queries")
public class RuleControllerImpl implements RuleController{

private static final Logger LOGGER = LoggerFactory.getLogger(RuleControllerImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
import io.netty.util.internal.StringUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Api;
import lombok.Setter;

@Component
@CrossOrigin
@Api(tags = {"Rule-test"}, description = "Test rules on Eiffel events")
public class RuleTestControllerImpl implements RuleTestController {
private static final Logger LOGGER = LoggerFactory.getLogger(RuleTestControllerImpl.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;

/**
* Endpoint /status should display EI back-end status and services Eiffel Intelligence is dependent
* on.
*/
@Component
@CrossOrigin
@Api(tags = {"Status"}, description = "Information of EI and its dependencies")
public class StatusControllerImpl implements StatusController {

private static final Logger LOGGER = LoggerFactory.getLogger(StatusControllerImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

@Component
@CrossOrigin
@Api(tags = {"Subscriptions"}, description = "Subscription handling requests")
public class SubscriptionControllerImpl implements SubscriptionController {

private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionControllerImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.servlet.http.HttpServletRequest;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
Expand All @@ -34,6 +35,7 @@

@Component
@CrossOrigin
@Api(tags = {"Templates"}, description = "Templates of rules, Eiffel events and subscriptions")
public class TemplateControllerImpl implements TemplateController {

private static final Logger LOGGER = LoggerFactory.getLogger(
Expand Down