Java Code Examples for org.eclipse.microprofile.openapi.annotations.headers.Header

The following examples show how to use org.eclipse.microprofile.openapi.annotations.headers.Header. These examples are extracted from open source projects. 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 Project: microprofile-open-api   Source File: ReviewResource.java    License: Apache License 2.0 6 votes vote down vote up
@GET
@APIResponse(
        responseCode = "200",
        description = "successful operation",
        content = @Content(
            mediaType = "application/json",
            schema = @Schema(
                type = SchemaType.ARRAY,
                implementation = Review.class
            )
        ),
        headers = @Header(ref="#/components/headers/Request-Limit")
    )
@Operation(
    operationId = "getAllReviews",
    summary = "get all the reviews"
)
@Produces("application/json")
public Response getAllReviews(){
    return Response.ok().entity(reviews.values()).build();
}
 
Example 2
Source Project: cxf   Source File: Sample.java    License: Apache License 2.0 6 votes vote down vote up
@Consumes({ MediaType.APPLICATION_JSON })
@POST
@Operation(
    summary = "Create new item",
    description = "Post operation with entity in a body"
)
@APIResponses(
    @APIResponse(
        content = @Content(
            schema = @Schema(implementation = Item.class), 
            mediaType = MediaType.APPLICATION_JSON
        ),
        headers = @Header(name = "Location"),
        responseCode = "201"
    )
)
public Response createItem(
    @Context final UriInfo uriInfo,
    @Parameter(required = true) final Item item) {
    items.put(item.getName(), item);
    return Response
        .created(uriInfo.getBaseUriBuilder().path(item.getName()).build())
        .entity(item).build();
}
 
Example 3
Source Project: smallrye-open-api   Source File: ResourceParameterTests.java    License: 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 4
Source Project: microprofile-open-api   Source File: ReviewResource.java    License: Apache License 2.0 4 votes vote down vote up
@GET
@Path("{id}")
@APIResponse(
        responseCode="200",
        description="Review retrieved",
        [email protected](
            [email protected](
                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 5
Source Project: microprofile-open-api   Source File: UserResource.java    License: Apache License 2.0 4 votes vote down vote up
@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();
        }