org.eclipse.microprofile.openapi.annotations.tags.Tag Java Examples

The following examples show how to use org.eclipse.microprofile.openapi.annotations.tags.Tag. 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: BookingResource.java    From microprofile-open-api with Apache License 2.0 6 votes vote down vote up
@GET
@Tag(ref="bookings")
@APIResponses(value={
        @APIResponse(
                responseCode="200",
                description="Bookings retrieved",
                content=@Content(
                    schema=@Schema(
                        type = SchemaType.ARRAY,
                        implementation=Booking.class))
                ),
            @APIResponse(
                responseCode="404",
                description="No bookings found for the user.")
})
@Operation(
    summary="Retrieve all bookings for current user",
    operationId = "getAllBookings")
@Produces("application/json")
public Response getBookings(){
    return Response.ok().entity(bookings.values()).build();
}
 
Example #2
Source File: BookingResource.java    From microprofile-open-api with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("{id}")
@Tag()
@APIResponse(
        responseCode="200",
        description="Booking deleted successfully."
    )
@APIResponse(
        responseCode="404",
        description="Booking not found."
    )
@Operation(
    summary="Delete a booking with ID",
    operationId = "deleteBookingById")
@Produces("text/plain")
public Response deleteBooking(
        @PathParam("id") int id){
            if(bookings.get(id)!=null) {
                bookings.remove(id);
                return Response.ok().build();
            }
            else {
                return Response.status(Status.NOT_FOUND).build();
            }
        }
 
Example #3
Source File: BeanValidationResourceTest.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
@Path("/test-container")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Tag(name = "Test", description = "Testing the container")
public BVTestContainer getTestContainer(BVTestResourceEntity parameter) {
    return new BVTestContainer();
}
 
Example #4
Source File: TimeService.java    From Hands-On-Enterprise-Java-Microservices-with-Eclipse-MicroProfile with MIT License 5 votes vote down vote up
@GET
@Path("/now")
@Produces(MediaType.APPLICATION_JSON)
@Tag(name = "time", description = "time service methods")
@ExternalDocumentation(description = "Basic World Clock API Home.",
        url = "http://worldclockapi.com/")
@Operation(summary = "Queries the WorldClockApi using the MP-RestClient",
        description = "Uses the WorldClockApi type proxy injected by the MP-RestClient to access the worldclockapi.com service")
public Now utc() {
    return clockApi.utc();
}
 
Example #5
Source File: UserResource.java    From microprofile-open-api with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/{username}")
@Tag(ref="user")
@APIResponses(value={
        @APIResponse(
                responseCode = "200",
                description = "Successfully retrieved user by user name.",
                content = @Content(
                    schema = @Schema(implementation = User.class)
                )),
            @APIResponse(
                responseCode = "400",
                description = "Invalid username supplied",
                content = @Content(
                        schema = @Schema(implementation = User.class)
                ))
})
@Operation(
    summary = "Get user by user name",
    operationId = "getUserByName")
public Response getUserByName(
    @Parameter(
        name = "username",
        schema = @Schema(type = SchemaType.STRING),
        required = true
        )
    @PathParam("username") String userName) throws NotFoundException {
        User user = userData.findUserByName(userName);
        if (null != user) {
            return Response.ok().entity(user).build();
        }
        else {
            throw new NotFoundException("User not found");
        }
    }
 
Example #6
Source File: JaxRsAnnotationScannerTest.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@PATCH
@Consumes(MediaType.TEXT_PLAIN)
@Tags({
        @Tag, @Tag
})
public void patchValue(String value) {
}
 
Example #7
Source File: UserResource.java    From microprofile-open-api with Apache License 2.0 5 votes vote down vote up
@DELETE
  @Path("/{username}")
  @Tag(ref="user")
  @APIResponse(
          responseCode = "200",
          description = "User deleted successfully"
          )
  @APIResponse(
          responseCode = "400",
          description = "Invalid username supplied"
          )
  @APIResponse(
          responseCode = "404",
          description = "User not found"
          )
  @Operation(
    summary = "Delete user",
    description = "This can only be done by the logged in user.",
    operationId = "deleteUser")
public Response deleteUser(
    @Parameter(
        name = "username",
        description = "The name that needs to be deleted",
        schema = @Schema(type = SchemaType.STRING),
        required = true
        )
    @PathParam("username") String userName) {
        if (userData.removeUser(userName)) {
            return Response.ok().entity("").build();
        }
        else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    }
 
Example #8
Source File: UserResource.java    From microprofile-open-api with Apache License 2.0 5 votes vote down vote up
@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 #9
Source File: UserResource.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@GET
@Path("/login")
@Tag()
@ExternalDocumentation(
        description = "Policy on user security.",
        url = "http://exampleurl.com/policy"
)
@APIResponse(
        responseCode = "200",
        description = "Successful user login.",
        content = @Content(
            schema = @Schema(implementation = User.class)
        )
    )
@APIResponse(
        responseCode = "400",
        description = "Invalid username/password supplied"
        )
@Operation(
    summary = "Logs user into the system",
    operationId = "logInUser"
)

@SecurityScheme(
    ref = "#/components/securitySchemes/httpTestScheme"
)
@SecurityRequirement(
    name = "httpTestScheme"
)
public Response loginUser(
    @Parameter(
        name = "username",
        description = "The user name for login",
        schema = @Schema(type = SchemaType.STRING),
        required = true
        )
    @QueryParam("username") String username,
    @Parameter(
        name = "password",
        description = "The password for login in clear text",
        schema = @Schema(type = SchemaType.STRING),
        required = true)
    @QueryParam("password") String password) {
        return Response.ok()
            .entity("logged in user session:" + System.currentTimeMillis())
            .build();
    }
 
Example #10
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 #11
Source File: UserResource.java    From microprofile-open-api with 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();
        }
 
Example #12
Source File: UserResource.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@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 #13
Source File: AvailabilityResource.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@GET
@Tag(
        name = "Get Flights",
        description = "method to retrieve all flights available",
        externalDocs = @ExternalDocumentation(
            description = "A list of all the flights offered by the app",
            url = "http://airlinesratingapp.com/ourflights")
    )
@Tag(ref="Availability")
@APIResponse(
        responseCode = "200",
        description = "successful operation",
        content = @Content(
            mediaType = "application/json",
            schema = @Schema(
                type = SchemaType.ARRAY,
                implementation = Flight.class
            )
        )
    )
@APIResponse(
        responseCode = "404",
        description = "No available flights found",
        content = @Content(
            mediaType = "n/a")
    )
@Operation(
    summary = "Retrieve all available flights",
    operationId = "getFlights")
@Produces("application/json")
public Response getFlights(
    @Parameter(
        ref = "#/components/parameters/departureDate"
    )
    @QueryParam("departureDate") String departureDate,
    @Parameter(
        name = "airportFrom",
        required = true,
        allowEmptyValue = true,
        description = "Airport the customer departs from",
        schema = @Schema(
            implementation = String.class)
    )
    @QueryParam("airportFrom") String airportFrom,
    @Parameter(
        name = "returningDate",
        required = true,
        allowReserved = true,
        description = "Customer return date",
        schema = @Schema(
            implementation = String.class)
        )
    @QueryParam("returningDate") String returningDate,
    @Parameter(
        name = "airportTo",
        required = true,
        description = "Airport the customer returns to",
        schema = @Schema(
            implementation = String.class)
    )
    @QueryParam("airportTo") String airportTo,
    @Parameter(
        name = "numberOfAdults",
        required = true,
        description = "Number of adults on the flight",
        schema = @Schema(
            minimum = "0",
            implementation = String.class)
    )
    @QueryParam("numberOfAdults") int numberOfAdults,
    @Parameter(
        name = "numberOfChildren",
        required = true,
        deprecated = true,
        description = "Number of children on the flight",
        schema = @Schema(
            minimum = "0",
            implementation = String.class)
    )
    @QueryParam("numberOfChildren") int numberOfChildren){
    return Response.ok().entity(findFlights(airportFrom, airportTo, departureDate, returningDate)).build();
}
 
Example #14
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 #15
Source File: JaxRsAnnotationScannerTest.java    From smallrye-open-api with Apache License 2.0 4 votes vote down vote up
@GET
@Produces(MediaType.TEXT_PLAIN)
@Tag(name = "tag3", description = "TAG3 from TagTestResource2#getValue1", externalDocs = @ExternalDocumentation(description = "Ext doc from TagTestResource2#getValue1"))
public String getValue1() {
    return null;
}
 
Example #16
Source File: JaxRsAnnotationScannerTest.java    From smallrye-open-api with Apache License 2.0 4 votes vote down vote up
@PATCH
@Consumes(MediaType.TEXT_PLAIN)
@Tag
public void patchValue(String value) {
}
 
Example #17
Source File: JaxRsAnnotationScannerTest.java    From smallrye-open-api with Apache License 2.0 4 votes vote down vote up
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Tag(name = "tag1", description = "TAG1 from TagTestResource1#postValue")
public void postValue(String value) {
}