Java Code Examples for org.eclipse.microprofile.openapi.annotations.enums.SchemaType#INTEGER

The following examples show how to use org.eclipse.microprofile.openapi.annotations.enums.SchemaType#INTEGER . 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: PetStoreResource.java    From microprofile-open-api with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/order/{orderId}")
@APIResponse(
        responseCode = "400", 
        description = "Invalid ID supplied"
        )
@APIResponse(
        responseCode = "404", 
        description = "Order not found"
        ) 
@Operation(
    summary = "Delete purchase order by ID",
    description = "For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors"
)
public Response deleteOrder(
    @Parameter(
        name = "orderId",
        description = "ID of the order that needs to be deleted",  
        schema = @Schema(
            type = SchemaType.INTEGER, 
            minimum = "1"
        ), 
        required = true
    )
    @PathParam("orderId") Long orderId) {
        if (storeData.deleteOrder(orderId)) {
            return Response.ok().entity("").build();
        } 
        else {
            return Response.status(Response.Status.NOT_FOUND).entity("Order not found").build();
        }
    }
 
Example 2
Source File: ResourceParameterTests.java    From smallrye-open-api with Apache License 2.0 4 votes vote down vote up
@Operation(summary = "Return all policies for a given account")
@GET
@Path("/")
@Parameters({
        @Parameter(name = "offset", in = ParameterIn.QUERY, description = "Page number, starts 0, if not specified uses 0.", schema = @Schema(type = SchemaType.INTEGER)),
        @Parameter(name = "limit", in = ParameterIn.QUERY, description = "Number of items per page, if not specified uses 10. "
                + "NO_LIMIT can be used to specify an unlimited page, when specified it ignores the offset", schema = @Schema(type = SchemaType.INTEGER)),
        @Parameter(name = "sortColumn", in = ParameterIn.QUERY, description = "Column to sort the results by", schema = @Schema(type = SchemaType.STRING, enumeration = {
                "name",
                "description",
                "is_enabled",
                "mtime"
        })),
        @Parameter(name = "sortDirection", in = ParameterIn.QUERY, description = "Sort direction used", schema = @Schema(type = SchemaType.STRING, enumeration = {
                "asc",
                "desc"
        })),
        @Parameter(name = "filter[name]", in = ParameterIn.QUERY, description = "Filtering policies by the name depending on the Filter operator used.", schema = @Schema(type = SchemaType.STRING)),
        @Parameter(name = "filter:op[name]", in = ParameterIn.QUERY, description = "Operations used with the filter", schema = @Schema(type = SchemaType.STRING, enumeration = {
                "equal",
                "like",
                "ilike",
                "not_equal"
        }, defaultValue = "equal")),
        @Parameter(name = "filter[description]", in = ParameterIn.QUERY, description = "Filtering policies by the description depending on the Filter operator used.", schema = @Schema(type = SchemaType.STRING)),
        @Parameter(name = "filter:op[description]", in = ParameterIn.QUERY, description = "Operations used with the filter", schema = @Schema(type = SchemaType.STRING, enumeration = {
                "equal",
                "like",
                "ilike",
                "not_equal"
        }, defaultValue = "equal")),
        @Parameter(name = "filter[is_enabled]", in = ParameterIn.QUERY, description = "Filtering policies by the is_enabled field."
                +
                "Defaults to true if no operand is given.", schema = @Schema(type = SchemaType.STRING, defaultValue = "true", enumeration = {
                        "true", "false" })),
})
@APIResponse(responseCode = "400", description = "Bad parameter for sorting was passed")
@APIResponse(responseCode = "404", description = "No policies found for customer")
@APIResponse(responseCode = "403", description = "Individual permissions missing to complete action")
@APIResponse(responseCode = "200", description = "Policies found", content = @Content(schema = @Schema(implementation = PagedResponse.class)), headers = @Header(name = "TotalCount", description = "Total number of items found", schema = @Schema(type = SchemaType.INTEGER)))
public Response getPoliciesForCustomer() {
    return null;
}
 
Example 3
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 4
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");
        }
    }
 
Example 5
Source File: PetStoreResource.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@GET
@Path("/order/{orderId}")
@Operation(
    summary = "Find purchase order by ID",
    description = "For valid response try integer IDs with value between the integers of 1 and 10. Other values will generated exceptions"
)
@APIResponse(
        responseCode = "200", 
        description = "successful operation",
        content = @Content(
            schema = @Schema(implementation = Order.class, 
              allOf = { Order.class, Pet.class },
              not = BadOrder.class )
        )
    )
@APIResponse(
        responseCode = "400", 
        description = "Invalid ID supplied",
        content = @Content(
            schema = @Schema(implementation = Order.class)
        )
    )
@APIResponse(
        responseCode = "404", 
        description = "Order not found",
        content = @Content(
            schema = @Schema(implementation = Order.class, 
              anyOf = { Order.class, BadOrder.class },
              discriminatorProperty = "id", 
              discriminatorMapping = @DiscriminatorMapping(value = "0", schema = BadOrder.class) )
        )
    )
@APIResponse(
        responseCode = "900", 
        description = "Invalid",
        content = @Content(
            schema = @Schema(implementation = Order.class, hidden = true)
        )
    )
public Response getOrderById(
    @Parameter(
        name = "orderId",
        description = "ID of pet that needs to be fetched", 
        schema = @Schema(
            type = SchemaType.INTEGER, 
            minimum = "1", 
            maximum = "10"), 
        required = true
    )
    @PathParam("orderId") Long orderId)
throws NotFoundException {
    Order order = storeData.findOrderById(orderId);
    if (null != order) {
        return Response.ok().entity(order).build();
    } 
    else {
        throw new NotFoundException(404, "Order not found");
    }
}