summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/OpenAPI2SpringBoot.java
diff options
context:
space:
mode:
authorManuel Bentele2021-12-23 15:13:52 +0100
committerManuel Bentele2021-12-23 15:13:52 +0100
commit14e7f8024066253b312b942b8f2f3491b5ef19d8 (patch)
treeb82e9017832621e24b9ee4952d1e27242a592574 /dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/OpenAPI2SpringBoot.java
parent[SERVER] Add Maven profile to generate server API automatically (diff)
downloadtutor-module-feature/dsmd-openapi.tar.gz
tutor-module-feature/dsmd-openapi.tar.xz
tutor-module-feature/dsmd-openapi.zip
[SERVER] Add source code of autogenerated server APIfeature/dsmd-openapi
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();
+ }
+
+}