JAVA-21455 Move SpringFox code out of spring-boot-mvc to spring-boot-mvc-legacy (#14212)
This commit is contained in:
@@ -7,7 +7,6 @@ This module contains articles about Spring Web MVC in Spring Boot projects.
|
||||
- [Custom Validation MessageSource in Spring Boot](https://www.baeldung.com/spring-custom-validation-message-source)
|
||||
- [Display RSS Feed with Spring MVC](https://www.baeldung.com/spring-mvc-rss-feed)
|
||||
- [A Controller, Service and DAO Example with Spring Boot and JSF](https://www.baeldung.com/jsf-spring-boot-controller-service-dao)
|
||||
- [Setting Up Swagger 2 with a Spring REST API Using Springfox](https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api)
|
||||
- [Using Spring ResponseEntity to Manipulate the HTTP Response](https://www.baeldung.com/spring-response-entity)
|
||||
- [The @ServletComponentScan Annotation in Spring Boot](https://www.baeldung.com/spring-servletcomponentscan)
|
||||
- [Guide to Internationalization in Spring Boot](https://www.baeldung.com/spring-boot-internationalization)
|
||||
|
||||
@@ -80,12 +80,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<!-- Spring Fox 2 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
<version>${spring.fox.version}</version>
|
||||
</dependency>
|
||||
<!-- AOP -->
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
@@ -113,7 +107,6 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring.fox.version>3.0.0</spring.fox.version>
|
||||
<!-- ROME for RSS -->
|
||||
<rome.version>1.10.0</rome.version>
|
||||
<javax.faces.version>2.3.7</javax.faces.version>
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.baeldung.swagger2boot;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.baeldung.swagger2boot.configuration;
|
||||
|
||||
import com.baeldung.swagger2boot.plugin.EmailAnnotationPlugin;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.data.rest.configuration.SpringDataRestConfiguration;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
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
|
||||
public class SpringFoxConfig {
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfo(
|
||||
"My REST API",
|
||||
"Some custom description of API.",
|
||||
"API TOS",
|
||||
"Terms of service",
|
||||
new Contact("John Doe", "www.example.com", "myeaddress@company.com"),
|
||||
"License of API",
|
||||
"API license URL",
|
||||
Collections.emptyList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket api() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EmailAnnotationPlugin emailPlugin() {
|
||||
return new EmailAnnotationPlugin();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.baeldung.swagger2boot.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class RegularRestController {
|
||||
|
||||
@GetMapping("home")
|
||||
public String getSession() {
|
||||
return "Hello";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.baeldung.swagger2boot.model;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@NotNull(message = "First Name cannot be null")
|
||||
private String firstName;
|
||||
|
||||
@Min(value = 15, message = "Age should not be less than 15")
|
||||
@Max(value = 65, message = "Age should not be greater than 65")
|
||||
private int age;
|
||||
|
||||
@Email(regexp=".*@.*\\..*", message = "Email should be valid")
|
||||
private String email;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.baeldung.swagger2boot.plugin;
|
||||
|
||||
import static springfox.bean.validators.plugins.Validators.annotationFromBean;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import springfox.bean.validators.plugins.Validators;
|
||||
import springfox.documentation.builders.StringElementFacetBuilder;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.schema.ModelPropertyBuilderPlugin;
|
||||
import springfox.documentation.spi.schema.contexts.ModelPropertyContext;
|
||||
|
||||
@Component
|
||||
@Order(Validators.BEAN_VALIDATOR_PLUGIN_ORDER)
|
||||
public class EmailAnnotationPlugin implements ModelPropertyBuilderPlugin {
|
||||
|
||||
@Override
|
||||
public boolean supports(DocumentationType delimiter) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* read Email annotation
|
||||
*/
|
||||
@Override
|
||||
public void apply(ModelPropertyContext context) {
|
||||
Optional<Email> email = annotationFromBean(context, Email.class);
|
||||
if (email.isPresent()) {
|
||||
context.getSpecificationBuilder().facetBuilder(StringElementFacetBuilder.class)
|
||||
.pattern(email.get().regexp());
|
||||
context.getSpecificationBuilder().example("email@email.com");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.baeldung.swagger2boot.repository;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baeldung.swagger2boot.model.User;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends CrudRepository<User, Long> {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user