Project

General

Profile

« Previous | Next » 

Revision 50003

  • Add swagger config.

View differences:

modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/config/SwaggerConfig.java
1 1
package eu.dnetlib.repo.manager.service.config;
2 2

  
3
import eu.dnetlib.repo.manager.service.controllers.MonitorApi;
4
import eu.dnetlib.repo.manager.service.controllers.PiWikApi;
5
import eu.dnetlib.repo.manager.service.controllers.RepositoryApi;
6
import eu.dnetlib.repo.manager.service.controllers.ValidatorApi;
3 7
import org.springframework.context.annotation.Bean;
8
import org.springframework.context.annotation.ComponentScan;
4 9
import org.springframework.context.annotation.Configuration;
5 10
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
6 11
import springfox.documentation.builders.PathSelectors;
......
11 16
import springfox.documentation.spi.DocumentationType;
12 17
import springfox.documentation.spring.web.plugins.Docket;
13 18
import springfox.documentation.swagger2.annotations.EnableSwagger2;
14

  
15 19
import java.util.ArrayList;
16 20

  
17
import static springfox.documentation.builders.PathSelectors.regex;
18 21

  
19 22
/**
20 23
 * Created by panagiotis on 16/11/2017.
......
22 25
@Configuration
23 26
@EnableSwagger2
24 27
@EnableWebMvc
28
@ComponentScan(basePackageClasses = {
29
        RepositoryApi.class,
30
        MonitorApi.class,
31
        ValidatorApi.class,
32
        PiWikApi.class
33
})
25 34
public class SwaggerConfig  {
26 35

  
27 36
    @Bean
28 37
    public Docket productApi() {
29 38
        return new Docket(DocumentationType.SWAGGER_2)
30
                .apiInfo(getApiInfo())
31 39
                .select()
32
                .apis(RequestHandlerSelectors.basePackage(("eu.dnetlib.repo.manager.service.controller")))
40
                .apis(RequestHandlerSelectors.any())
33 41
                .paths(PathSelectors.any())
34
                .build();
42
                .build()
43
                .pathMapping("/")
44
                .apiInfo(getApiInfo());
35 45
    }
36 46

  
37 47
    private ApiInfo getApiInfo() {
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/ValidatorApi.java
2 2

  
3 3
import eu.dnetlib.domain.functionality.validator.JobForValidation;
4 4
import eu.dnetlib.domain.functionality.validator.RuleSet;
5
import io.swagger.annotations.Api;
5 6
import org.json.JSONException;
6 7
import org.springframework.http.MediaType;
7 8
import org.springframework.web.bind.annotation.*;
......
11 12

  
12 13
@RestController
13 14
@RequestMapping(value = "/validator")
15
@Api(description = "Validator API",  tags = {"validator"})
14 16
public interface ValidatorApi {
15 17

  
16 18
    @RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE )
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/MonitorApi.java
3 3
import eu.dnetlib.api.functionality.ValidatorServiceException;
4 4
import eu.dnetlib.domain.functionality.validator.StoredJob;
5 5
import eu.dnetlib.repo.manager.shared.JobsOfUser;
6
import io.swagger.annotations.Api;
6 7
import org.json.JSONException;
7 8
import org.springframework.http.MediaType;
8 9
import org.springframework.web.bind.annotation.*;
9 10

  
10 11
@RestController
11 12
@RequestMapping(value = "/monitor")
13
@Api(description = "Monitor API",  tags = {"monitor"})
12 14
public interface MonitorApi {
13 15

  
14 16
    @RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.GET,consumes = MediaType.APPLICATION_JSON_VALUE,
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApi.java
14 14

  
15 15
@RestController
16 16
@RequestMapping(value = "/repository")
17
@Api(description = "Repository API",  tags = {"repository"})
17 18
public interface RepositoryApi {
18

  
19

  
19
    
20 20
    @RequestMapping(value = "/testAggregations", method = RequestMethod.GET,
21 21
            produces = MediaType.APPLICATION_JSON_VALUE)
22 22
    @ResponseBody
......
31 31
    @ResponseBody
32 32
    List<Repository> getRepositoriesByCountry(String country,String mode) throws JSONException;
33 33

  
34
    @RequestMapping(value = "/getRepositoriesOfUser/{userEmail}/{page}/{size}")
34
    @RequestMapping(value = "/getRepositoriesOfUser/{userEmail}/{page}/{size}",method = RequestMethod.GET,
35
            produces = MediaType.APPLICATION_JSON_VALUE)
35 36
    @ResponseBody
36 37
    List<Repository> getRepositoriesOfUser(String userEmail,
37 38
                                           String page,
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java
8 8
import eu.dnetlib.domain.data.Repository;
9 9
import eu.dnetlib.domain.data.RepositoryInterface;
10 10
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
11
import io.swagger.annotations.Api;
11 12
import org.apache.log4j.Logger;
12 13
import org.json.JSONArray;
13 14
import org.json.JSONException;
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApi.java
2 2

  
3 3

  
4 4
import eu.dnetlib.domain.data.PiwikInfo;
5
import io.swagger.annotations.Api;
5 6
import org.springframework.http.MediaType;
6 7
import org.springframework.web.bind.annotation.*;
7 8

  
8 9
import java.util.List;
9 10

  
10 11
@RestController
11
@RequestMapping(value = "/piwi")
12
@RequestMapping(value = "/piwik")
13
@Api(description = "Piwik API",  tags = {"piwik"})
12 14
public interface PiWikApi {
13 15

  
14 16

  
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApi.java
2 2

  
3 3
import eu.dnetlib.repo.manager.shared.BrokerException;
4 4
import eu.dnetlib.repo.manager.shared.broker.*;
5
import io.swagger.annotations.*;
5 6
import org.json.JSONException;
6 7
import org.springframework.http.MediaType;
7 8
import org.springframework.web.bind.annotation.*;
......
12 13

  
13 14
@RestController
14 15
@RequestMapping(value = "/broker")
16
@Api(description = "Broker API",  tags = {"broker"})
15 17
public interface BrokerApi {
16 18

  
17 19
    @RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
modules/uoa-repository-manager-service/src/main/webapp/WEB-INF/applicationContext.xml
12 12

  
13 13
    <import resource="classpath*:/application-context.xml"/>
14 14

  
15
    <!-- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>-->
15 16

  
16
    <import resource="classpath:META-INF/cxf/cxf.xml"/>
17
   <!-- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>-->
18
    <import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml"/>
19
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
20
    <import resource="classpath*:/cxf.xml"/>
21
    <import resource="classpath*:/eu/dnetlib/repos/ehcacher/springContext-repos-ehcacher.xml"/>
22
    <import resource="classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml"/>
23
    <import resource="classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml"/>
24
    <import resource="classpath*:/eu/dnetlib/users/springContext-users-ldap.xml"/>
25
    <import resource="classpath*:/gr/uoa/di/driver/util/springContext-locators.xml"/>
26
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml"/>
27
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml"/>
28
    <import resource="classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml"/>
29
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/>
30
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/>
17
      <import resource="classpath:META-INF/cxf/cxf.xml"/>
31 18

  
32
    <import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/>
19
     <import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml"/>
20
     <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
21
     <import resource="classpath*:/cxf.xml"/>
22
     <import resource="classpath*:/eu/dnetlib/repos/ehcacher/springContext-repos-ehcacher.xml"/>
23
     <import resource="classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml"/>
24
     <import resource="classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml"/>
25
     <import resource="classpath*:/eu/dnetlib/users/springContext-users-ldap.xml"/>
26
     <import resource="classpath*:/gr/uoa/di/driver/util/springContext-locators.xml"/>
27
     <import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml"/>
28
     <import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml"/>
29
     <import resource="classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml"/>
30
     <import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/>
31
     <import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/>
33 32

  
33
     <import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/>
34

  
34 35
    <context:property-placeholder location="classpath*:/eu/**/application.properties" />
35 36

  
36 37
    <bean class="eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader" id="propertyLoader">
......
90 91
    <mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/"/>
91 92
    <mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
92 93
    <bean class="eu.dnetlib.repo.manager.service.config.SwaggerConfig"/>
93

  
94 94
</beans>
modules/uoa-repository-manager-service/pom.xml
214 214
        <dependency>
215 215
            <groupId>io.springfox</groupId>
216 216
            <artifactId>springfox-swagger-ui</artifactId>
217
            <version>2.7.0</version>
217
            <version>2.7.1-SNAPSHOT</version>
218 218
        </dependency>
219

  
220 219
    </dependencies>
221 220

  
222 221

  
223

  
224 222
</project>

Also available in: Unified diff