All Downloads are FREE. Search and download functionalities are using the official Maven repository.

JavaJaxRS.libraries.jersey3.bootstrap.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
package {{apiPackage}};

import java.util.stream.Collectors;
import java.util.stream.Stream;

import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder;
import io.swagger.v3.oas.integration.*;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.info.*;

import {{javaxPackage}}.servlet.http.HttpServlet;
import {{javaxPackage}}.servlet.ServletConfig;
import {{javaxPackage}}.servlet.ServletException;

public class Bootstrap extends HttpServlet {

  private static final long serialVersionUID = 20230810;   

  @Override
  public void init(ServletConfig config) throws ServletException {
  
    Info info = new Info()
      .title("{{title}}")
      .description("{{{appDescription}}}")
      .termsOfService("{{termsOfService}}")
      .contact(new Contact()
        .email("{{infoEmail}}"))
      .license(new License()
        .name("{{licenseInfo}}")
        .url("{{licenseUrl}}"));

    OpenAPI oas = new OpenAPI();
    oas.info(info);

    SwaggerConfiguration openApiConfig = new SwaggerConfiguration()
        .openAPI(oas)
        .prettyPrint(true)
        .resourcePackages(Stream.of("io.swagger.sample.resource").collect(Collectors.toSet()));
    
    try {
        new JaxrsOpenApiContextBuilder()
            .servletConfig(config)
            .openApiConfiguration(openApiConfig)
            .buildContext(true);
            
    } catch (OpenApiConfigurationException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy