summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/OpenAPI2SpringBoot.java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/OpenAPI2SpringBoot.java')
-rw-r--r--dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/OpenAPI2SpringBoot.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/OpenAPI2SpringBoot.java b/dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/OpenAPI2SpringBoot.java
new file mode 100644
index 00000000..258ef11a
--- /dev/null
+++ b/dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/OpenAPI2SpringBoot.java
@@ -0,0 +1,57 @@
+package org.openslx.bwlp.sat.api.handler;
+
+import com.fasterxml.jackson.databind.Module;
+import org.openapitools.jackson.nullable.JsonNullableModule;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.ExitCodeGenerator;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@SpringBootApplication
+@ComponentScan(basePackages = {"org.openslx.bwlp.sat.api.handler", "org.openslx.bwlp.sat.api.handler" , "org.openapitools.configuration"})
+public class OpenAPI2SpringBoot implements CommandLineRunner {
+
+ @Override
+ public void run(String... arg0) throws Exception {
+ if (arg0.length > 0 && arg0[0].equals("exitcode")) {
+ throw new ExitException();
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ new SpringApplication(OpenAPI2SpringBoot.class).run(args);
+ }
+
+ static class ExitException extends RuntimeException implements ExitCodeGenerator {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public int getExitCode() {
+ return 10;
+ }
+
+ }
+
+ @Bean
+ public WebMvcConfigurer webConfigurer() {
+ return new WebMvcConfigurer() {
+ /*@Override
+ public void addCorsMappings(CorsRegistry registry) {
+ registry.addMapping("/**")
+ .allowedOrigins("*")
+ .allowedMethods("*")
+ .allowedHeaders("Content-Type");
+ }*/
+ };
+ }
+
+ @Bean
+ public Module jsonNullableModule() {
+ return new JsonNullableModule();
+ }
+
+}