SwaggerConfig.java 2.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
package adt.mainnode.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Tag;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.Collections;

import static springfox.documentation.builders.PathSelectors.regex;

@EnableSwagger2
@Configuration
public class SwaggerConfig {

    @Bean
    public Docket DocketApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("ADT Main Node")
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(regex("/(vlans|configurations|nlp|virt_query|event|presence_check).*"))
                .build()
                .apiInfo(metaInfo())
                .tags(
                        new Tag("Vlans", "Endpoints to create new assets or to retrieve existing ones."),
                        new Tag("Configurations", "Endpoint queried by distributed nodes the first time they start up. Grants them a scanning configuration.")  ,
                        new Tag("NLP", "Natural Language Processing functionalities."),
                        new Tag("Virt_Query", "Endpoint to query the Virtuoso Database."),
                        new Tag("(Event) Transfer Service", "Endpoint to send vulnerabilities' events to a pre-set URL.")
                );
    }

    private ApiInfo metaInfo() {
        return new ApiInfo(
                "ADT Main Node",
                "This is the online documentation of ADT Main Node. Click authorize to perform queries with your own credentials.",
                "ALPHA 2",
                "Terms of service",
                new Contact("Roberto Garrido",
                        "https://medal.ctb.upm.es/roberto-garrido-garcia",
                        "roberto.garrido@ctb.upm.es"),
                "License",
                "License URL",
                Collections.emptyList()
        );
    }

}