Java Code Examples for org.eclipse.microprofile.openapi.annotations.enums.ParameterIn#PATH

The following examples show how to use org.eclipse.microprofile.openapi.annotations.enums.ParameterIn#PATH . 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: ParameterScanTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("unused")
@Parameter(name = "X-Custom-Header", in = ParameterIn.HEADER, required = true)
@Parameter(name = "id", in = ParameterIn.PATH)
public Widget get(@HeaderParam("X-Custom-Header") String custom,
        @PathParam("id") @DefaultValue("000") String id) {
    return null;
}
 
Example 2
Source File: ParameterScanTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
@Parameter(name = "id", in = ParameterIn.PATH, style = ParameterStyle.MATRIX, description = "Additional information for id2")
public Widget get(@MatrixParam("m1") @DefaultValue("default-m1") String m1,
        @MatrixParam("m2") @Size(min = 20) String m2) {
    return null;
}
 
Example 3
Source File: ParameterScanTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/seg1/seg2/resourceA")
@Produces(MediaType.APPLICATION_JSON)
@Parameter(in = ParameterIn.PATH, name = "resourceA", style = ParameterStyle.MATRIX)
public Widget get(@MatrixParam("m1") @DefaultValue("default-m1") int m1,
        @MatrixParam("m2") @DefaultValue("100") @Max(200) int m2) {
    return null;
}
 
Example 4
Source File: ParameterScanTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@GET
@Path("seg1")
@Produces(MediaType.TEXT_PLAIN)
@Parameter(name = "segments", description = "Test", style = ParameterStyle.MATRIX, in = ParameterIn.PATH)
public String echo(@PathParam("segments") PathSegment segmentsMatrix) {
    return segmentsMatrix.getPath();
}
 
Example 5
Source File: ParameterScanTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@GET
@Path("{p1}")
@Produces(MediaType.TEXT_PLAIN)
public String echo(
        @Parameter(name = "Path1", in = ParameterIn.PATH, style = ParameterStyle.SIMPLE, description = "The name 'Path1' will not be used instead of 'p1'") @PathParam("p1") String p1) {
    return p1;
}
 
Example 6
Source File: BookingResource.java    From microprofile-open-api with Apache License 2.0 5 votes vote down vote up
@GET
@Path("{id}")
@Parameters(
    {
        @Parameter(
                    name = "id",
                    description = "ID of the booking",
                    required = true,
                    in = ParameterIn.PATH,
                    style = ParameterStyle.SIMPLE
                )
        }
        )

@Produces("application/json")
@Operation(
    summary="Get a booking with ID",
    operationId = "getBookingById")
@APIResponses(value={
        @APIResponse(
                responseCode="200",
                description="Booking retrieved",
                content=@Content(
                    schema=@Schema(
                        implementation=Booking.class))),
        @APIResponse(
                responseCode="404",
                description="Booking not found")
})
public Response getBooking(
    @PathParam("id") int id){
        Booking booking = bookings.get(id);
        if(booking!=null){
            return Response.ok().entity(booking).build();
        }
        else{
            return Response.status(Status.NOT_FOUND).build();
        }
    }
 
Example 7
Source File: ResourceInheritanceTests.java    From smallrye-open-api with Apache License 2.0 4 votes vote down vote up
@PathParam("from")
@Parameter(name = "from", in = ParameterIn.PATH, description = "The name of the person sending the greeting")
void setFromName(String from);
 
Example 8
Source File: ResourceInheritanceTests.java    From smallrye-open-api with Apache License 2.0 4 votes vote down vote up
@Override
@Parameter(name = "from", in = ParameterIn.PATH, style = ParameterStyle.SIMPLE)
public void setFromName(String from) {
    this.from = from;
}
 
Example 9
Source File: ReviewResource.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@GET
@Path("{id}")
@APIResponse(
        responseCode="200",
        description="Review retrieved",
        content=@Content(
            schema=@Schema(
                implementation=Review.class)),
        headers = {
                @Header(
                    name = "responseHeader1",
                    description = "Max rate", 
                    schema = @Schema(type = SchemaType.INTEGER), 
                    required = true, 
                    allowEmptyValue = true, 
                    deprecated = true),
                @Header(
                    name = "responseHeader2",
                    description = "Input value", 
                    schema = @Schema(type = SchemaType.STRING), 
                    required = true, 
                    allowEmptyValue = true, 
                    deprecated = true
                )
        })
@APIResponse(
        responseCode="404",
        description="Review not found")
@Operation(
    operationId = "getReviewById",
    summary="Get a review with ID"
)
@Produces("application/json")
public Response getReviewById(
        @Parameter(
            name = "id",
            description = "ID of the booking",
            required = true,
            in = ParameterIn.PATH,
            content = @Content(
                examples = @ExampleObject(
                    name = "example",
                    value = "1")))
        @PathParam("id") int id){
    Review review = reviews.get(id);
    if(review!=null){
        return Response.ok().entity(review).build();
    }
    else{
        return Response.status(Status.NOT_FOUND).build();
    }
}
 
Example 10
Source File: ReviewResource.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@GET
@Path("users/{user}")
@Operation(
    operationId = "getReviewByUser",
    summary="Get all reviews by user")
@APIResponses(value={
        @APIResponse(
                responseCode="200",
                description="Review(s) retrieved",
                content=@Content(
                    schema=@Schema(
                        implementation=Review.class))),
        @APIResponse(
                responseCode="404",
                description="Review(s) not found")
})
@Produces("application/json")
public Response getReviewByUser(
    @Parameter(
        name = "user",
        description = "username of the user for the reviews",
        required = true,
        in = ParameterIn.PATH,
        content = @Content(
            examples = @ExampleObject(
                name = "example",
                value = "bsmith")),
        examples = { @ExampleObject(name="example1", value="bsmith"), @ExampleObject(name="example2", value="[email protected]")})
    @PathParam("user") String user){

        List<Review> reviewsByUser = new ArrayList<Review>();
        for (Review review : reviews.values()) {
            User currentUser = review.getUser();
            if (currentUser.getUserName() == user) {
                reviewsByUser.add(review);
            }
        }
        if(!reviewsByUser.isEmpty()){
            return Response.ok().entity(reviewsByUser).build();
        }
        else{
            return Response.status(Status.NOT_FOUND).build();
        }
}
 
Example 11
Source File: ReviewResource.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@GET
@Path("airlines/{airline}")
@Operation(
    operationId = "getReviewByAirline",
    summary="Get all reviews by airlines")
@Parameter(
        name = "airline",
        description = "name of the airlines for the reviews",
        required = true,
        in = ParameterIn.PATH,
        content = @Content(
            examples = @ExampleObject(
                name = "example",
                value = "Acme Air")),
        example = "Acme Air")
@APIResponse(
        responseCode="200",
        description="Review(s) retrieved",
        content=@Content(
            schema=@Schema(
                implementation=Review.class)))
@APIResponse(
        responseCode="404",
        description="Review(s) not found")
@Produces("application/json")
public Response getReviewByAirline(
    @Parameter(
        name = "airline",
        description = "name of the airlines for the reviews",
        required = true,
        in = ParameterIn.PATH,
        content = @Content(
            examples = @ExampleObject(
                value = "Acme Air")))
    @PathParam("airline") String airlines){

        List<Review> reviewsByAirlines = new ArrayList<Review>();
        for (Review review : reviews.values()) {
            Airline currentAirline = review.getAirlines();
            if (currentAirline.getName() == airlines) {
                reviewsByAirlines.add(review);
            }
        }
        if(!reviewsByAirlines.isEmpty()){
            return Response.ok().entity(reviewsByAirlines).build();
        }
        else{
            return Response.status(Status.NOT_FOUND).build();
        }
}
 
Example 12
Source File: ReviewResource.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@GET
@Path("{user}/{airlines}")
@APIResponse(
        responseCode="200",
        description="Review(s) retrieved",
        content=@Content(
            schema=@Schema(
            implementation=Review.class)))
@APIResponse(
        responseCode="404",
        description="Review(s) not found")
@Operation(
    operationId = "getReviewByAirlineAndUser",
    summary="Get all reviews for an airline by User")
@Produces("application/json")
@Parameters(
    value = {
        @Parameter(
            name = "airlines",
            description = "name of the airlines for the reviews",
            required = true,
            in = ParameterIn.PATH,
            content = @Content(
                example = "Acme Air")),
        @Parameter(
            name = "user",
            description = "sername of the user for the reviews",
            required = true,
            in = ParameterIn.PATH,
            content = @Content(
                examples = @ExampleObject(
                    name = "example",
                    value = "bsmith")))
        })
public Response getReviewByAirlineAndUser(
    @PathParam("user") String user,
    @PathParam("airlines") String airlines){
        List<Review> reviewsByAirlinesUser = new ArrayList<Review>();
        for (Review review : reviews.values()) {
            Airline currentAirline = review.getAirlines();
            User currentUser = review.getUser();

            if (currentAirline.getName() == airlines && currentUser.getUserName() == user) {
                reviewsByAirlinesUser.add(review);
            }
        }
        if(!reviewsByAirlinesUser.isEmpty()){
            return Response.ok().entity(reviewsByAirlinesUser).build();
        }
        else{
            return Response.status(Status.NOT_FOUND).build();
        }
}