forked from microprofile/microprofile-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.
Merge pull request microprofile#329 from phillip-kruger/master
Baby steps: Adding support for PUT and DELETE in Spring
- Loading branch information
Showing
21 changed files
with
813 additions
and
102 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
47 changes: 47 additions & 0 deletions
47
.../test/java/test/io/smallrye/openapi/runtime/scanner/resources/GreetingDeleteResource.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,47 @@ | ||
package test.io.smallrye.openapi.runtime.scanner.resources; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.DELETE; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; | ||
|
||
/** | ||
* JAX-RS. | ||
* Some basic tests, mostly to compare with the Spring implementation | ||
* | ||
* @author Phillip Kruger ([email protected]) | ||
*/ | ||
@Path("/greeting") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
public class GreetingDeleteResource { | ||
|
||
// 1) Basic path var test | ||
@DELETE | ||
@Path("/greet/{id}") | ||
public void greet(@PathParam("id") String id) { | ||
|
||
} | ||
|
||
// 2) Response where you do not have a type. | ||
@DELETE | ||
@Path("/greetWithResponse/{id}") | ||
@APIResponse(responseCode = "204", description = "No Content") | ||
public Response greetWithResponse(@PathParam("id") String id) { | ||
return Response.noContent().build(); | ||
} | ||
|
||
// 3) Response with a type specified (No JaxRS comparison) (repeat of above as there is not wrapped type return | ||
@DELETE | ||
@Path("/greetWithResponseTyped/{id}") | ||
@APIResponse(responseCode = "204", description = "No Content") | ||
public Response greetWithResponseTyped(@PathParam("id") String id) { | ||
return Response.noContent().build(); | ||
} | ||
|
||
} |
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
51 changes: 51 additions & 0 deletions
51
...src/test/java/test/io/smallrye/openapi/runtime/scanner/resources/GreetingPutResource.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,51 @@ | ||
package test.io.smallrye.openapi.runtime.scanner.resources; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.PUT; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
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 test.io.smallrye.openapi.runtime.scanner.entities.Greeting; | ||
|
||
/** | ||
* JAX-RS. | ||
* Some basic tests, mostly to compare with the Spring implementation | ||
* | ||
* @author Phillip Kruger ([email protected]) | ||
*/ | ||
@Path("/greeting") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
public class GreetingPutResource { | ||
|
||
// 1) Basic path var test | ||
@PUT | ||
@Path("/greet/{id}") | ||
public Greeting greet(Greeting greeting, @PathParam("id") String id) { | ||
return greeting; | ||
} | ||
|
||
// 2) Response where you do not have a type. | ||
@PUT | ||
@Path("/greetWithResponse/{id}") | ||
@APIResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(ref = "#/components/schemas/Greeting"))) | ||
public Response greetWithResponse(Greeting greeting, @PathParam("id") String id) { | ||
return Response.ok(greeting).build(); | ||
} | ||
|
||
// 3) Response with a type specified (No JaxRS comparison) (repeat of above as there is not wrapped type return | ||
@PUT | ||
@Path("/greetWithResponseTyped/{id}") | ||
@APIResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(ref = "#/components/schemas/Greeting"))) | ||
public Response greetWithResponseTyped(Greeting greeting, @PathParam("id") String id) { | ||
return Response.ok(greeting).build(); | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
.../io/smallrye/openapi/runtime/scanner/resource.testBasicJaxRsDeleteDefinitionScanning.json
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,56 @@ | ||
{ | ||
"openapi" : "3.0.1", | ||
"paths" : { | ||
"/greeting/greet/{id}" : { | ||
"delete" : { | ||
"parameters" : [ { | ||
"name" : "id", | ||
"in" : "path", | ||
"required" : true, | ||
"schema" : { | ||
"type" : "string" | ||
} | ||
} ], | ||
"responses" : { | ||
"204" : { | ||
"description" : "No Content" | ||
} | ||
} | ||
} | ||
}, | ||
"/greeting/greetWithResponse/{id}" : { | ||
"delete" : { | ||
"parameters" : [ { | ||
"name" : "id", | ||
"in" : "path", | ||
"required" : true, | ||
"schema" : { | ||
"type" : "string" | ||
} | ||
} ], | ||
"responses" : { | ||
"204" : { | ||
"description" : "No Content" | ||
} | ||
} | ||
} | ||
}, | ||
"/greeting/greetWithResponseTyped/{id}" : { | ||
"delete" : { | ||
"parameters" : [ { | ||
"name" : "id", | ||
"in" : "path", | ||
"required" : true, | ||
"schema" : { | ||
"type" : "string" | ||
} | ||
} ], | ||
"responses" : { | ||
"204" : { | ||
"description" : "No Content" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.