org.eclipse.microprofile.openapi.annotations.parameters.RequestBody Java Examples
The following examples show how to use
org.eclipse.microprofile.openapi.annotations.parameters.RequestBody.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ComponentResource.java From component-runtime with Apache License 2.0 | 7 votes |
@POST @Path("migrate/{id}/{configurationVersion}") @Operation(operationId = "migrateComponent", description = "Allows to migrate a component configuration without calling any component execution.") @APIResponse(responseCode = "200", description = "the new configuration for that component (or the same if no migration was needed).", content = @Content(mediaType = APPLICATION_JSON)) @APIResponse(responseCode = "404", description = "The component is not found", content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(type = OBJECT, implementation = ErrorPayload.class))) Map<String, String> migrate( @PathParam("id") @Parameter(name = "id", description = "the component identifier", in = PATH) String id, @PathParam("configurationVersion") @Parameter(name = "configurationVersion", description = "the configuration version you send", in = PATH) int version, @RequestBody(description = "the actual configuration in key/value form.", required = true, content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(type = OBJECT))) Map<String, String> config);
Example #2
Source File: TrellisHttpResource.java From trellis with Apache License 2.0 | 6 votes |
/** * Perform a PUT operation on a LDP Resource. * * @param uriInfo the URI info * @param secContext the security context * @param headers the HTTP headers * @param request the request * @param body the body * @return the async response */ @PUT @Timed @Operation(summary = "Create or update a linked data resource") public CompletionStage<Response> setResource(@Context final Request request, @Context final UriInfo uriInfo, @Context final HttpHeaders headers, @Context final SecurityContext secContext, @RequestBody(description = "The updated resource") final InputStream body) { final TrellisRequest req = new TrellisRequest(request, uriInfo, headers, secContext); final String urlBase = getBaseUrl(req); final IRI identifier = buildTrellisIdentifier(req.getPath()); final PutHandler putHandler = new PutHandler(req, body, trellis, extensions, preconditionRequired, createUncontained, urlBase); return getParent(identifier).thenCombine(trellis.getResourceService().get(identifier), putHandler::initialize) .thenCompose(putHandler::setResource).thenCompose(putHandler::updateMemento) .thenApply(ResponseBuilder::build).exceptionally(this::handleException); }
Example #3
Source File: TrellisHttpResource.java From trellis with Apache License 2.0 | 6 votes |
/** * Perform a POST operation on a LDP Resource. * * @param uriInfo the URI info * @param secContext the security context * @param headers the HTTP headers * @param request the request * @param body the body * @return the async response */ @POST @Timed @Operation(summary = "Create a linked data resource") public CompletionStage<Response> createResource(@Context final Request request, @Context final UriInfo uriInfo, @Context final HttpHeaders headers, @Context final SecurityContext secContext, @RequestBody(description = "The new resource") final InputStream body) { final TrellisRequest req = new TrellisRequest(request, uriInfo, headers, secContext); final String urlBase = getBaseUrl(req); final String path = req.getPath(); final String identifier = getIdentifier(req); final String separator = path.isEmpty() ? "" : "/"; final IRI parent = buildTrellisIdentifier(path); final IRI child = buildTrellisIdentifier(path + separator + identifier); final PostHandler postHandler = new PostHandler(req, parent, identifier, body, trellis, extensions, urlBase); return trellis.getResourceService().get(parent) .thenCombine(trellis.getResourceService().get(child), postHandler::initialize) .thenCompose(postHandler::createResource).thenCompose(postHandler::updateMemento) .thenApply(ResponseBuilder::build).exceptionally(this::handleException); }
Example #4
Source File: TrellisHttpResource.java From trellis with Apache License 2.0 | 6 votes |
/** * Perform a PATCH operation on an LDP Resource. * * @param uriInfo the URI info * @param secContext the security context * @param headers the HTTP headers * @param request the request * @param body the body * @return the async response */ @PATCH @Timed @Operation(summary = "Update a linked data resource") public CompletionStage<Response> updateResource(@Context final Request request, @Context final UriInfo uriInfo, @Context final HttpHeaders headers, @Context final SecurityContext secContext, @RequestBody(description = "The update request for RDF resources, typically as SPARQL-Update", required = true, content = @Content(mediaType = "application/sparql-update")) final String body) { final TrellisRequest req = new TrellisRequest(request, uriInfo, headers, secContext); final String urlBase = getBaseUrl(req); final IRI identifier = buildTrellisIdentifier(req.getPath()); final PatchHandler patchHandler = new PatchHandler(req, body, trellis, extensions, supportsCreateOnPatch, defaultJsonLdProfile, urlBase); return getParent(identifier).thenCombine(trellis.getResourceService().get(identifier), patchHandler::initialize) .thenCompose(patchHandler::updateResource).thenCompose(patchHandler::updateMemento) .thenApply(ResponseBuilder::build).exceptionally(this::handleException); }
Example #5
Source File: ConfigurationTypeResource.java From component-runtime with Apache License 2.0 | 6 votes |
@POST @Path("migrate/{id}/{configurationVersion}") @Operation(operationId = "migrateConfiguration", description = "Allows to migrate a configuration without calling any component execution.") @APIResponse(responseCode = "200", description = "the new values for that configuration (or the same if no migration was needed).", content = @Content(mediaType = APPLICATION_JSON)) @APIResponse(responseCode = "400", description = "If the configuration is missing, payload will be an ErrorPayload with the code CONFIGURATION_MISSING.", content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(type = OBJECT, implementation = ErrorPayload.class))) @APIResponse(responseCode = "404", description = "The configuration is not found", content = @Content(mediaType = APPLICATION_JSON)) Map<String, String> migrate( @PathParam("id") @Parameter(name = "id", description = "the configuration identifier", in = PATH) String id, @PathParam("configurationVersion") @Parameter(name = "configurationVersion", description = "the configuration version you send", in = PATH) int version, @RequestBody(description = "the actual configuration in key/value form.", required = true, content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(type = OBJECT))) Map<String, String> config);
Example #6
Source File: RequestBodyScanTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@POST @Path("post/{id}") @Consumes("multipart/related") @RequestBody(required = true) @SuppressWarnings("unused") public void post(@org.jboss.resteasy.annotations.jaxrs.PathParam("id") String id, MultipartRelatedInput input) { }
Example #7
Source File: ParameterScanTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@POST @Path("/widgets/create") @Consumes(MediaType.APPLICATION_JSON) @Operation(operationId = "createWidget") public void createWidget( @RequestBody(required = true, content = @Content(schema = @Schema(implementation = Widget.class))) final Widget w) { }
Example #8
Source File: ParameterScanTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) @RequestBody(content = @Content(schema = @Schema(requiredProperties = { "f3" }), encoding = { @Encoding(name = "formField1", contentType = "text/x-custom-type") })) public CompletableFuture<Widget> upd(@MultipartForm Bean form, @FormParam("f3") @DefaultValue("3") int formField3, @org.jboss.resteasy.annotations.jaxrs.FormParam @NotNull String formField4) { return null; }
Example #9
Source File: ParameterScanTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") @POST @Path("/n8") @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.TEXT_PLAIN) public Optional<String> helloName8(@RequestBody Optional<Bean> bean) { return null; }
Example #10
Source File: ResourceParameterTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@POST @Consumes("application/json") @Produces("application/json") @Operation(summary = "Convert an array of integer types to an array of floating point types") @RequestBody(content = @Content(schema = @Schema(anyOf = { int[].class, long[].class }))) @APIResponses({ @APIResponse(responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(oneOf = { float[].class, double[].class }))) }) public Object intToFloat(@SuppressWarnings("unused") Object input) { return null; }
Example #11
Source File: BulkReadResource.java From component-runtime with Apache License 2.0 | 5 votes |
@POST @Operation(description = "Takes a request aggregating N other endpoint requests and responds all results " + "in a normalized HTTP response representation.") @APIResponse(responseCode = "200", description = "The request payloads.", content = @Content(mediaType = APPLICATION_JSON)) CompletionStage<BulkResponses> bulk(@RequestBody(description = "the action parameters as a flat map of strings", required = true, content = @Content(mediaType = APPLICATION_JSON)) final BulkRequests requests);
Example #12
Source File: PersonResource.java From blog-tutorials with MIT License | 5 votes |
@POST public Response createNewPerson(@Context UriInfo uriInfo, @RequestBody Person personToStore) { entityManager.persist(personToStore); var headerLocation = uriInfo.getAbsolutePathBuilder() .path(personToStore.getId().toString()) .build(); return Response.created(headerLocation).build(); }
Example #13
Source File: LegumeApi.java From quarkus-in-prod with Apache License 2.0 | 5 votes |
@POST @Operation( operationId = "AddLegume", summary = "Add a Legume" ) @RequestBody( content = @Content( mediaType = APPLICATION_JSON, schema = @Schema(implementation = LegumeNew.class, ref = "legume_new")), description = "The Legume to create", required = true ) @APIResponse( responseCode = "201", description = "Legume created", content = @Content( mediaType = APPLICATION_JSON, schema = @Schema(implementation = Legume.class, ref = "error")) ) @APIResponse( name = "notFound", responseCode = "400", description = "Legume data is invalid" ) @APIResponse( name = "notFound", responseCode = "404", description = "Legume provision not found" ) @APIResponse( name = "internalError", responseCode = "500", description = "Internal Server Error" ) public Response add(@Valid final LegumeNew legume);
Example #14
Source File: UserResource.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@POST @Path("/createWithList") @Tag(ref="user") @Tags(refs="create") @APIResponse( responseCode = "200", description = "Successfully created list of users." ) @APIResponse( responseCode = "400", description = "Unable to create list of users." ) @Operation( summary = "Creates list of users with given input list", //List of User objects operationId = "createUsersFromList" ) public Response createUsersWithListInput( @RequestBody( description = "List of user object", required = true ) java.util.List<User> users) { for (User user : users) { userData.addUser(user); } return Response.ok().entity("").build(); }
Example #15
Source File: PetResource.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@POST @Consumes({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"}) @SecurityRequirement( name = "petsApiKey" ) @APIResponse( responseCode = "400", description = "Invalid input", content = @Content( mediaType = "application/json", schema = @Schema(implementation = ApiResponse.class)) ) @RequestBody( name="pet", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Pet.class), examples = @ExampleObject(ref = "http://example.org/petapi-examples/openapi.json#/components/examples/pet-example") ), required = true, description = "example of a new pet to add" ) @Operation( summary = "Add pet to store", description = "Add a new pet to the store" ) public Response addPet(Pet pet) { Pet updatedPet = petData.addPet(pet); return Response.ok().entity(updatedPet).build(); }
Example #16
Source File: BookingResource.java From microprofile-open-api with Apache License 2.0 | 4 votes |
@POST @SecurityRequirement( name = "bookingSecurityScheme", scopes = {"write:bookings", "read:bookings"} ) @Callback( name = "bookingCallback", callbackUrlExpression = "http://localhost:9080/airlines/bookings", operations = @CallbackOperation( method ="get", summary="Retrieve all bookings for current user", responses={ @APIResponse( responseCode="200", description="Bookings retrieved", content=@Content( mediaType="application/json", schema=@Schema( type = SchemaType.ARRAY, implementation=Booking.class)) ), @APIResponse( responseCode="404", description="No bookings found for the user.") })) @APIResponse( responseCode="201", description="Booking created", content = @Content( schema=@Schema( name= "id", description = "id of the new booking", type=SchemaType.STRING ) ) ) @Operation( summary="Create a booking", description = "Create a new booking record with the booking information provided.", operationId = "createBooking" ) @Consumes("application/json") @Produces("application/json") public Response createBooking(@RequestBody( description = "Create a new booking with the provided information.", content = @Content( mediaType = "application/json", schema = @Schema(ref="Booking"), examples = @ExampleObject( name = "booking", summary = "External booking example", externalValue = "http://foo.bar/examples/booking-example.json" ) )) Booking task) { bookings.put(currentId, task); return Response.status(Status.CREATED).entity("{\"id\":" + currentId++ + "}").build(); }
Example #17
Source File: UserResource.java From microprofile-open-api with Apache License 2.0 | 4 votes |
@Path("/{username}") @PUT @RequestBody( name = "user", description = "Record of a new user to be created in the system.", content = @Content( mediaType = "application/json", schema = @Schema(implementation = User.class), examples = @ExampleObject( name = "user", summary = "Example user properties to update", value = "Properties to update in JSON format here" ) ) ) @Operation( summary = "Update user", description = "This can only be done by the logged in user.", operationId = "updateUser") @APIResponses(value={ @APIResponse( responseCode = "200", description = "User updated successfully", content = @Content( schema = @Schema(ref="User"), encoding = @Encoding( name = "password", contentType = "text/plain", style = "form", allowReserved = true, explode = true, headers = @Header(ref="Max-Rate") ) ) ), @APIResponse( responseCode = "400", description = "Invalid user supplied" ), @APIResponse( responseCode = "404", description = "User not found" ) }) @Tag(ref="user") public Response updateUser( @Parameter( name = "username", description = "User that needs to be updated", schema = @Schema(type = SchemaType.STRING), required = true ) @PathParam("username") String username, User user) { userData.addUser(user); return Response.ok().entity("").build(); }
Example #18
Source File: UserResource.java From microprofile-open-api with Apache License 2.0 | 4 votes |
@POST @Path("/createWithArray") @Tag(ref="user") @Tag(ref="create") @APIResponse( responseCode = "200", description = "Successfully created list of users." ) @APIResponse( responseCode = "400", description = "Unable to create list of users." ) @Operation( summary = "Creates list of users with given input array", //Array of User objects operationId = "createUsersFromArray" /* tags = {"user"}, //this operation intentionally doesn't have tags attribute, since above Tag ref should apply */ ) public Response createUsersWithArrayInput( @RequestBody( description = "Array of user object", required = true, content = @Content( mediaType = "application/json", schema = @Schema( type = SchemaType.ARRAY, implementation = User.class, nullable = true, writeOnly = true, minItems = 2, maxItems = 20, uniqueItems = true ), encoding = @Encoding( name = "firstName", contentType = "text/plain", style = "form", allowReserved = true, explode = true ) ) ) User[] users) { for (User user : users) { userData.addUser(user); } return Response.ok().entity("").build(); }
Example #19
Source File: ReviewResource.java From microprofile-open-api with Apache License 2.0 | 4 votes |
@POST @Callbacks( {@Callback( name = "testCallback", callbackUrlExpression="http://localhost:9080/oas3-airlines/reviews", operations = @CallbackOperation( summary = "Get all reviews", method = "get", responses = @APIResponse( responseCode = "200", description = "successful operation", content = @Content( mediaType = "application/json", schema = @Schema( type = SchemaType.ARRAY, implementation = Review.class ) ) ) ) ) } ) @Tag(ref="Reviews") @Servers(value={ @Server(url = "localhost:9080/{proxyPath}/reviews/id", description = "view of all the reviews", variables = { @ServerVariable(name = "proxyPath", description = "Base path of the proxy", defaultValue = "proxy") }), @Server(url = "http://random.url/reviews", description = "random text") }) @SecurityRequirement( name = "reviewoauth2", scopes = "write:reviews") @APIResponse( responseCode="201", description="review created", content = @Content( schema = @Schema( name= "id", description = "id of the new review", type = SchemaType.STRING)), links = { @Link( name="Review", description="get the review that was added", operationId="getReviewById", server = @Server( description = "endpoint for all the review related methods", url = "http://localhost:9080/airlines/reviews/"), parameters = @LinkParameter( name = "reviewId", expression = "$request.path.id") ) } ) @RequestBody( ref = "#/components/requestBodies/review" ) @Operation( summary="Create a Review", operationId = "createReview" ) @Consumes("application/json") @Produces("application/json") public Response createReview(Review review) { reviews.put(currentId, review); return Response.status(Status.CREATED).entity("{\"id\":" + currentId++ + "}").build(); }
Example #20
Source File: JsonIgnorePropertiesResource.java From smallrye-open-api with Apache License 2.0 | 4 votes |
@POST @Path("/ignoreProperties") public String getIgnoreProperties(@RequestBody IgnoreProps ignoreProps) { return "Type extension value."; }
Example #21
Source File: RequestBodyTestApplication.java From smallrye-open-api with Apache License 2.0 | 4 votes |
@POST @Consumes(MediaType.APPLICATION_JSON) @Path("defaults") public void testDefaults(@RequestBody(required = true) SomeObject body) { return; }
Example #22
Source File: RequestBodyTestApplication.java From smallrye-open-api with Apache License 2.0 | 4 votes |
@POST @Path("ref") @Consumes public void testRef(@RequestBody(ref = "test") SomeObject body) { return; }
Example #23
Source File: RequestBodyTestApplication.java From smallrye-open-api with Apache License 2.0 | 4 votes |
@POST @Path("impl") public void testImpl( @RequestBody(content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = DifferentObject.class)), required = true) SomeObject body) { return; }