simplify swagger ex, fix start

This commit is contained in:
Loredana 2018-11-18 17:12:59 +02:00
parent b970aaac58
commit 9ec41d973b
7 changed files with 4 additions and 85 deletions

View File

@ -2,10 +2,8 @@ package com.baeldung.swaggerboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = {"com.baeldung"})
public class Application {
public static void main(String[] args) {

View File

@ -1,16 +0,0 @@
package com.baeldung.swaggerboot;
public class Constants {
public static final String DEFAULT_GREETING = "Howdy Cosmic Spheroid!";
public static final String DEFAULT_ERROR = "Fail!";
/**
* API Endpoint.
*/
public static final String REACTIVE_REST_URL = "/reactiverest";
public static final String FUNCTIONAL_URL = "/functional";
public static final String REGULAR_REST_URL = "/regularrest";
}

View File

@ -1,7 +1,5 @@
package com.baeldung.swaggerboot.configuration;
import com.fasterxml.classmate.TypeResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@ -21,9 +19,6 @@ import java.util.Collections;
@ComponentScan("com.baeldung.swaggerboot.controller")
public class SpringFoxConfig {
@Autowired
private TypeResolver typeResolver;
private ApiInfo apiInfo() {
return new ApiInfo(
"My REST API",

View File

@ -1,22 +1,14 @@
package com.baeldung.swaggerboot.controller;
import com.baeldung.swaggerboot.services.RegularWebService;
import com.baeldung.swaggerboot.transfer.CustomResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import static com.baeldung.swaggerboot.Constants.REGULAR_REST_URL;
@RestController
public class RegularRestController {
@Autowired
RegularWebService regularWebService;
@GetMapping(REGULAR_REST_URL)
public CustomResponse getSession() {
return regularWebService.example();
@GetMapping("home")
public String getSession() {
return "Hello";
}
}

View File

@ -1,20 +0,0 @@
package com.baeldung.swaggerboot.services;
import com.baeldung.swaggerboot.transfer.CustomResponse;
import org.springframework.stereotype.Service;
import static com.baeldung.swaggerboot.Constants.DEFAULT_ERROR;
import static com.baeldung.swaggerboot.Constants.DEFAULT_GREETING;
@Service
public class RegularWebService {
public CustomResponse example() {
try {
return new CustomResponse(0, DEFAULT_GREETING);
} catch (Exception ex) {
return new CustomResponse(0, DEFAULT_ERROR);
}
}
}

View File

@ -1,31 +0,0 @@
package com.baeldung.swaggerboot.transfer;
public class CustomResponse {
private int id;
private String note;
public CustomResponse() {}
public CustomResponse(int id, String note) {
this.id = id;
this.note = note;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
}

View File

@ -0,0 +1 @@
spring.main.allow-bean-definition-overriding=true