forked from smallrye/smallrye-open-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support of HttpServletRequest, HttpServletResponse and HttpSession ty…
…pes in SpringAnnotationScanner (smallrye#1829) * Implemented isFrameworkContextType() in SpringAnnotationScanner * Apply suggestions from code review on Use the newer jakarta classes Co-authored-by: Michael Edgar <[email protected]> * Now Jakarta classes are managed too * Readded test scope to javax.servlet-api dep --------- Co-authored-by: Leonardo Moretti <[email protected]> Co-authored-by: Michael Edgar <[email protected]>
- Loading branch information
1 parent
47fd3da
commit 7a5232b
Showing
8 changed files
with
306 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...e/openapi/runtime/scanner/resources/jakarta/GreetingPostControllerWithServletContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package test.io.smallrye.openapi.runtime.scanner.resources.jakarta; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import jakarta.servlet.http.HttpSession; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.media.Content; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import test.io.smallrye.openapi.runtime.scanner.entities.Greeting; | ||
|
||
/** | ||
* Spring. | ||
* Some basic test, comparing with what we get in the JAX-RS version. | ||
* See the GreetingPostResource in the JAX-RS test | ||
* | ||
* @author Phillip Kruger ([email protected]) | ||
*/ | ||
@RestController | ||
@RequestMapping(value = "/greeting", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) | ||
public class GreetingPostControllerWithServletContext { | ||
|
||
// 1) Basic path var test | ||
@PostMapping("/greet") | ||
public Greeting greet(HttpServletRequest request, HttpServletResponse response, @RequestBody Greeting greeting) { | ||
return greeting; | ||
} | ||
|
||
// 2) ResponseEntity without a type specified | ||
@PostMapping("/greetWithResponse") | ||
@APIResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(ref = "#/components/schemas/Greeting"))) | ||
public ResponseEntity greetWithResponse(@RequestBody Greeting greeting, HttpServletRequest request, | ||
HttpServletResponse response) { | ||
return ResponseEntity.ok(greeting); | ||
} | ||
|
||
// 3) ResponseEntity with a type specified (No JaxRS comparison) | ||
@PostMapping("/greetWithResponseTyped") | ||
public ResponseEntity<Greeting> greetWithResponseTyped(HttpSession session, @RequestBody Greeting greeting) { | ||
return ResponseEntity.ok(greeting); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...ye/openapi/runtime/scanner/resources/jakarta/GreetingPutControllerWithServletContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package test.io.smallrye.openapi.runtime.scanner.resources.jakarta; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import jakarta.servlet.http.HttpSession; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.media.Content; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import test.io.smallrye.openapi.runtime.scanner.entities.Greeting; | ||
|
||
/** | ||
* Spring. | ||
* Some basic test, comparing with what we get in the JAX-RS version. | ||
* See the GreetingPutResource in the JAX-RS test | ||
* | ||
* @author Phillip Kruger ([email protected]) | ||
*/ | ||
@RestController | ||
@RequestMapping(value = "/greeting", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) | ||
public class GreetingPutControllerWithServletContext { | ||
|
||
// 1) Basic path var test | ||
@PutMapping("/greet/{id}") | ||
public Greeting greet(HttpServletRequest request, HttpServletResponse response, @RequestBody Greeting greeting, | ||
@PathVariable(name = "id") String id) { | ||
return greeting; | ||
} | ||
|
||
// 2) ResponseEntity without a type specified | ||
@PutMapping("/greetWithResponse/{id}") | ||
@APIResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(ref = "#/components/schemas/Greeting"))) | ||
public ResponseEntity greetWithResponse(@RequestBody Greeting greeting, @PathVariable(name = "id") String id, | ||
HttpServletRequest request, HttpServletResponse response) { | ||
return ResponseEntity.ok(greeting); | ||
} | ||
|
||
// 3) ResponseEntity with a type specified (No JaxRS comparison) | ||
@PutMapping("/greetWithResponseTyped/{id}") | ||
public ResponseEntity<Greeting> greetWithResponseTyped(HttpSession session, @RequestBody Greeting greeting, | ||
@PathVariable(name = "id") String id) { | ||
return ResponseEntity.ok(greeting); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...rye/openapi/runtime/scanner/resources/javax/GreetingPostControllerWithServletContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package test.io.smallrye.openapi.runtime.scanner.resources.javax; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.media.Content; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import test.io.smallrye.openapi.runtime.scanner.entities.Greeting; | ||
|
||
/** | ||
* Spring. | ||
* Some basic test, comparing with what we get in the JAX-RS version. | ||
* See the GreetingPostResource in the JAX-RS test | ||
* | ||
* @author Phillip Kruger ([email protected]) | ||
*/ | ||
@RestController | ||
@RequestMapping(value = "/greeting", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) | ||
public class GreetingPostControllerWithServletContext { | ||
|
||
// 1) Basic path var test | ||
@PostMapping("/greet") | ||
public Greeting greet(HttpServletRequest request, HttpServletResponse response, @RequestBody Greeting greeting) { | ||
return greeting; | ||
} | ||
|
||
// 2) ResponseEntity without a type specified | ||
@PostMapping("/greetWithResponse") | ||
@APIResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(ref = "#/components/schemas/Greeting"))) | ||
public ResponseEntity greetWithResponse(@RequestBody Greeting greeting, HttpServletRequest request, | ||
HttpServletResponse response) { | ||
return ResponseEntity.ok(greeting); | ||
} | ||
|
||
// 3) ResponseEntity with a type specified (No JaxRS comparison) | ||
@PostMapping("/greetWithResponseTyped") | ||
public ResponseEntity<Greeting> greetWithResponseTyped(HttpSession session, @RequestBody Greeting greeting) { | ||
return ResponseEntity.ok(greeting); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...lrye/openapi/runtime/scanner/resources/javax/GreetingPutControllerWithServletContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package test.io.smallrye.openapi.runtime.scanner.resources.javax; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.media.Content; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import test.io.smallrye.openapi.runtime.scanner.entities.Greeting; | ||
|
||
/** | ||
* Spring. | ||
* Some basic test, comparing with what we get in the JAX-RS version. | ||
* See the GreetingPutResource in the JAX-RS test | ||
* | ||
* @author Phillip Kruger ([email protected]) | ||
*/ | ||
@RestController | ||
@RequestMapping(value = "/greeting", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) | ||
public class GreetingPutControllerWithServletContext { | ||
|
||
// 1) Basic path var test | ||
@PutMapping("/greet/{id}") | ||
public Greeting greet(HttpServletRequest request, HttpServletResponse response, @RequestBody Greeting greeting, | ||
@PathVariable(name = "id") String id) { | ||
return greeting; | ||
} | ||
|
||
// 2) ResponseEntity without a type specified | ||
@PutMapping("/greetWithResponse/{id}") | ||
@APIResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(ref = "#/components/schemas/Greeting"))) | ||
public ResponseEntity greetWithResponse(@RequestBody Greeting greeting, @PathVariable(name = "id") String id, | ||
HttpServletRequest request, HttpServletResponse response) { | ||
return ResponseEntity.ok(greeting); | ||
} | ||
|
||
// 3) ResponseEntity with a type specified (No JaxRS comparison) | ||
@PutMapping("/greetWithResponseTyped/{id}") | ||
public ResponseEntity<Greeting> greetWithResponseTyped(HttpSession session, @RequestBody Greeting greeting, | ||
@PathVariable(name = "id") String id) { | ||
return ResponseEntity.ok(greeting); | ||
} | ||
} |