Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

NPE in sample/java-spring-boot-mvc #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.benjaminsproule.sample.springboot.mvc;

public enum AEnum {

A, B, C;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.benjaminsproule.sample.springboot.mvc;

public enum DEnum {

D, E, F;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.benjaminsproule.sample.springboot.mvc;

public class EnumWrapper<T extends Enum<T>> {

private String name;

private T enumeration;

public EnumWrapper() {
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public T getEnumeration() {
return enumeration;
}

public void setEnumeration(T enumeration) {
this.enumeration = enumeration;
}

@Override
public String toString() {
return "EnumWrapper{" +
"name='" + name + '\'' +
", enumeration=" + enumeration +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@SpringBootApplication(scanBasePackages = "com.benjaminsproule.sample.springboot.mvc")
public class SampleApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package com.benjaminsproule.sample.springboot.mvc;

import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class SampleResource {

@RequestMapping(method = RequestMethod.GET, path = "/sample", produces = "application/json")
@ApiOperation(value = "Return hello message", response = String.class)
public String home() {
return "{\"Hello\": \"World!\"}";
@GetMapping(path = "/home", produces = "application/json")
@ApiOperation(value = "Return hello message")
public ResponseEntity<String> home() {
return ResponseEntity.ok("{\"Hello\": \"World!\"}");
}

@PostMapping(path = "/transform")
@ApiOperation(value = "Transform enum")
public ResponseEntity<EnumWrapper<AEnum>> transform(EnumWrapper<DEnum> enumWrapper) {
return ResponseEntity.ok(new EnumWrapper<>());
}
}