add swagger-API and example controller
This commit is contained in:
15
build.gradle
15
build.gradle
@ -1,3 +1,5 @@
|
||||
import com.github.spotbugs.SpotBugsTask
|
||||
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.2.5.RELEASE'
|
||||
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
|
||||
@ -11,7 +13,12 @@ spotbugs{
|
||||
reportLevel = "high"
|
||||
toolVersion = '4.0.0-RC1'
|
||||
}
|
||||
<<<<<<< Updated upstream
|
||||
tasks.withType(com.github.spotbugs.SpotBugsTask) {
|
||||
=======
|
||||
|
||||
tasks.withType(SpotBugsTask) {
|
||||
>>>>>>> Stashed changes
|
||||
reports {
|
||||
html {
|
||||
enabled = true
|
||||
@ -52,8 +59,14 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
<<<<<<< Updated upstream
|
||||
implementation 'org.keycloak:keycloak-spring-boot-starter:9.0.0'
|
||||
implementation 'org.keycloak.bom:keycloak-adapter-bom:3.3.0.Final'
|
||||
=======
|
||||
implementation 'mops:styleguide:2.0.0'
|
||||
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.7.0'
|
||||
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.7.0'
|
||||
>>>>>>> Stashed changes
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
developmentOnly 'org.springframework.boot:spring-boot-devtools'
|
||||
runtimeOnly 'com.h2database:h2'
|
||||
@ -62,8 +75,10 @@ dependencies {
|
||||
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
|
||||
}
|
||||
testImplementation 'org.springframework.security:spring-security-test'
|
||||
compile('org.springframework.boot:spring-boot-starter-web')
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,22 @@ package mops.gruppen2;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
public class Gruppen2Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Gruppen2Application.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket productAPI(){
|
||||
return new Docket(DocumentationType.SWAGGER_2).select()
|
||||
.apis(RequestHandlerSelectors.basePackage("mops.gruppen2")).build();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package mops.gruppen2.controllers;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class SwaggerAPIController {
|
||||
@RequestMapping(value = "/products", method = RequestMethod.GET)
|
||||
public List<String> getProducts(){
|
||||
List<String> productList = new ArrayList<>();
|
||||
productList.add("Honey");
|
||||
productList.add("Almond");
|
||||
return productList;
|
||||
}
|
||||
@RequestMapping(value = "/products", method = RequestMethod.POST)
|
||||
public String createProduct() {
|
||||
return "Product is saved successfully";
|
||||
}
|
||||
}
|
@ -9,9 +9,15 @@ spring.datasource.username=root
|
||||
spring.datasource.password=geheim
|
||||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
|
||||
keycloak.principal-attribute=preferred_username
|
||||
keycloak.auth-server-url=https://keycloak.cs.hhu.de/auth
|
||||
keycloak.realm=MOPS
|
||||
keycloak.resource=demo
|
||||
keycloak.public-client=true
|
||||
=======
|
||||
spring.security.user.name=root
|
||||
spring.security.user.password=1234
|
||||
spring.security.user.roles=ADMIN
|
||||
>>>>>>> Stashed changes
|
||||
|
Reference in New Issue
Block a user