org.eclipse.microprofile.openapi.annotations.servers.Server Java Examples

The following examples show how to use org.eclipse.microprofile.openapi.annotations.servers.Server. 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: ReviewResource.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@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 #2
Source File: UserResource.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@GET
@Path("/{id}")
@Tag(ref="user")
@APIResponse(
        responseCode = "200",
        description = "Successfully retrieved user by id.",
        content = @Content(
            schema = @Schema(implementation = User.class)),
        links = { 
            @Link(
                name = "User name",
                description = "The username corresponding to provided user id",
                operationId = "getUserByName",
                parameters = @LinkParameter(
                    name = "userId",
                    expression = "$request.path.id")),
            @Link(
                 name = "Review",
                 description = "The reviews provided by user",
                 operationRef = "/db/reviews/{userName}",
                 parameters = @LinkParameter(
                     name = "path.userName",
                     expression = "$response.body#userName"),
                 requestBody = "$request.path.id",
                 server = @Server(url = "http://example.com"))
        }
        )
@APIResponse(
        responseCode = "400",
        description = "Invalid id supplied",
        content = @Content(
            schema = @Schema(implementation = User.class)
        ))
@Operation(
    summary = "Get user by id",
    operationId = "getUserById")
public Response getUserById(
    @Parameter(
        name = "id",
        description = "The name that needs to be fetched. Use 1 for testing.",
        schema = @Schema(type = SchemaType.INTEGER),
        required = true
    )
    @PathParam("id") int id) throws NotFoundException {
        User user = userData.findUserById(id);
        if (null != user) {
        return Response.ok().entity(user).build();
        }
        else {
        throw new NotFoundException("User not found");
        }
    }