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

The following examples show how to use org.eclipse.microprofile.openapi.annotations.enums.SchemaType. 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: smallrye-open-api   Source File: ExtensionParsingTests.java    License: Apache License 2.0 6 votes vote down vote up
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
@Callbacks({
        @Callback(name = "extendedCallback", callbackUrlExpression = "http://localhost:8080/resources/ext-callback", operations = @CallbackOperation(summary = "Get results", extensions = {
                @Extension(name = "x-object", value = "{ \"key\":\"value\" }", parseValue = true),
                @Extension(name = "x-object-unparsed", value = "{ \"key\":\"value\" }"),
                @Extension(name = "x-array", value = "[ \"val1\",\"val2\" ]", parseValue = true),
                @Extension(name = "x-booltrue", value = "true", parseValue = true),
                @Extension(name = "x-boolfalse", value = "false", parseValue = true),
                @Extension(name = "x-number", value = "42", parseValue = true),
                @Extension(name = "x-number-sci", value = "42e55", parseValue = true),
                @Extension(name = "x-positive-number-remains-string", value = "+42", parseValue = true),
                @Extension(name = "x-negative-number", value = "-42", parseValue = true),
                @Extension(name = "x-unparsable-number", value = "-Not.A.Number", parseValue = true)
        }, method = "get", responses = @APIResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(type = SchemaType.ARRAY, implementation = String.class)))))
})
public String get(String data) {
    return data;
}
 
Example 2
Source Project: quarkus   Source File: TestResource.java    License: Apache License 2.0 6 votes vote down vote up
@GET
@Path("/openapi/responses/{version}")
@Produces("application/json")
@APIResponses({
        @APIResponse(content = @Content(mediaType = "application/json", schema = @Schema(type = SchemaType.OBJECT, implementation = MyOpenApiEntityV1.class))),
        @APIResponse(content = @Content(mediaType = "application/json", schema = @Schema(type = SchemaType.OBJECT, implementation = MyOpenApiEntityV2.class)))
})
public Response openApiResponses(@PathParam("version") String version) {
    if ("v1".equals(version)) {
        MyOpenApiEntityV1 entityV1 = new MyOpenApiEntityV1();
        entityV1.setName("my openapi entity version one name");
        return Response.ok(entityV1).build();
    }

    MyOpenApiEntityV2 entityV2 = new MyOpenApiEntityV2();
    entityV2.setName("my openapi entity version two name");
    entityV2.setValue(version);
    return Response.ok(entityV2).build();
}
 
Example 3
Source Project: microprofile-open-api   Source File: BookingResource.java    License: Apache License 2.0 6 votes vote down vote up
@GET
@Tag(ref="bookings")
@APIResponses(value={
        @APIResponse(
                responseCode="200",
                description="Bookings retrieved",
                [email protected](
                    [email protected](
                        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 4
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 5
@GET
@APIResponses(value = {
	@APIResponse(
      responseCode = "404",
      description = "Author Not Found"
    ),
    @APIResponse(
      responseCode = "200",
      description = "Author with requested name",
      content = @Content(
        mediaType = "application/json",
        schema = @Schema(implementation = Author.class)
      )
    ),
    @APIResponse(
      responseCode = "500",
      description = "Internal service error"  	      
    )
})
@Operation(
	    summary = "Get specific author",
	    description = "Get specific author"
)
public Response getAuthor(@Parameter(
           description = "The unique name of the author",
           required = true,
           example = "Niklas Heidloff",
           schema = @Schema(type = SchemaType.STRING))
		@QueryParam("name") String name) {
			
		System.out.println("com.ibm.authors.GetAuthor.getAuthor /getauthor invoked");
	
		Author author = new Author();
		author.name = "Niklas Heidloff";
		author.twitter = "https://twitter.com/nheidloff";
		author.blog = "http://heidloff.net";

		return Response.ok(this.createJson(author)).build();
}
 
Example 6
Source Project: smallrye-open-api   Source File: ParameterResource.java    License: Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/unnamed")
@APIResponse(responseCode = "204", description = "No content")
public Response deleteTaskWithoutParamName(
        @Parameter(description = "The id of the task", example = "e1cb23d0-6cbe-4a29", schema = @Schema(type = SchemaType.STRING)) @PathParam("taskId") String taskId,
        @QueryParam("nextTask") String nextTaskId) {
    return Response.noContent().build();
}
 
Example 7
Source Project: smallrye-open-api   Source File: ParameterResource.java    License: Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/named")
@APIResponse(responseCode = "204", description = "No content")
public Response deleteTaskWithParamName(
        @Parameter(description = "The id of the task, invalid name discarded when @Parameter and JAX-RS annotation have same target", name = "notTaskId", example = "e1cb23d0-6cbe-4a29", schema = @Schema(type = SchemaType.STRING)) @PathParam("taskId") String taskId) {
    return Response.noContent().build();
}
 
Example 8
@GET
@Produces(MediaType.TEXT_PLAIN)
@Operation
@APIResponse(responseCode = "200", description = "A successful response", content = @Content(schema = @Schema(type = SchemaType.STRING)))
public String getPublicResponse() {
    return "response value";
}
 
Example 9
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
@Callbacks({
        @Callback(name = "extendedCallback", callbackUrlExpression = "http://localhost:8080/resources/ext-callback", operations = @CallbackOperation(summary = "Get results", extensions = {
                @Extension(name = "x-object", value = "{ \"key\":\"value\" }", parseValue = true),
                @Extension(name = "x-object-unparsed", value = "{ \"key\":\"value\" }"),
                @Extension(name = "x-array", value = "[ \"val1\",\"val2\" ]", parseValue = true),
                @Extension(name = "x-booltrue", value = "true", parseValue = false)
        }, method = "get", responses = @APIResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(type = SchemaType.ARRAY, implementation = String.class)))))
})
public String get(String data) {
    return data;
}
 
Example 10
Source Project: quarkus   Source File: TestResource.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("/openapi/responses")
@Produces("application/json")
@APIResponse(content = @Content(mediaType = "application/json", schema = @Schema(type = SchemaType.OBJECT, implementation = MyOpenApiEntityV1.class)))
public Response openApiResponse() {
    MyOpenApiEntityV1 entity = new MyOpenApiEntityV1();
    entity.setName("my openapi entity name");
    return Response.ok(entity).build();
}
 
Example 11
Source Project: microprofile-open-api   Source File: UserResource.java    License: 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 12
Source Project: microprofile-open-api   Source File: UserResource.java    License: 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 13
Source Project: microprofile-open-api   Source File: PetStoreResource.java    License: 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 14
Source Project: microprofile-open-api   Source File: PetResource.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("/findByTags")
@Produces("application/json")
@Callback(
    name = "tagsCallback",
    callbackUrlExpression = "http://petstoreapp.com/pet",
    operations = @CallbackOperation(
        method = "GET",
        summary = "Finds Pets by tags",
        description = "Find Pets by tags; Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
        responses = {
            @APIResponse(
                responseCode = "400",
                description = "Invalid tag value",
                content = @Content(mediaType = "none")
            ),
            @APIResponse(
                responseCode = "200",
                content = @Content(
                    mediaType = "application/json",
                    schema = @Schema(type = SchemaType.ARRAY, implementation = Pet.class))
                )
        }
    )
)
@APIResponseSchema(Pet[].class)
@Deprecated
public Response findPetsByTags(
    @HeaderParam("apiKey") String apiKey,
    @Parameter(
        name = "tags",
        description = "Tags to filter by",
        required = true,
        deprecated = true,
        schema = @Schema(implementation = String.class, deprecated = true,
          externalDocs = @ExternalDocumentation(description = "Pet Types", url = "http://example.com/pettypes"),
          enumeration = { "Cat", "Dog", "Lizard" }, defaultValue = "Dog" ))
    @QueryParam("tags") String tags) {
        return Response.ok(petData.findPetByTags(tags)).build();
    }
 
Example 15
Source Project: microprofile-open-api   Source File: UserResource.java    License: Apache License 2.0 5 votes vote down vote up
@PUT
@Path("/{username}")
@APIResponse(
        responseCode = "400",
        description = "Invalid user supplied"
    )
@APIResponse(
        responseCode = "404",
        description = "User not found"
    )
@Operation(
    summary = "Updated user",
    description = "This can only be done by the logged in user."
)
@SecurityRequirementsSet(
    value = {
        @SecurityRequirement(
            name = "userApiKey"
        ),
        @SecurityRequirement(
            name = "userBearerHttp"
        )
    }
)
public Response updateUser(
    @Parameter(
        name = "username",
        description = "name that need to be deleted",
        schema = @Schema(type = SchemaType.STRING),
        required = true
    )
    @PathParam("username") String username,
    @Parameter(
        description = "Updated user object",
        required = true) User user) {
            userData.addUser(user);
            return Response.ok().entity("").build();
        }
 
Example 16
Source Project: microprofile-open-api   Source File: UserResource.java    License: Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/{username}")
@APIResponses(value={
        @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."
)
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 17
Source Project: microprofile-open-api   Source File: UserResource.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("/login")
@APIResponse(
        responseCode = "200",
        description = "successful operation",
        content = @Content(
            schema = @Schema(implementation = String.class)
        )
    )
@APIResponse(
        responseCode = "400",
        description = "Invalid username/password supplied",
        content = @Content(
            schema = @Schema(implementation = String.class)
        )
    )
@Operation(
    summary = "Logs user into the system"
)
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 18
Source Project: cxf   Source File: Sample.java    License: Apache License 2.0 5 votes vote down vote up
@Produces({ MediaType.APPLICATION_JSON })
@GET
@Operation(
    summary = "Get all items",
    description = "Get operation with Response and @Default value"
)
@APIResponses(
    @APIResponse(
        content = @Content(schema = @Schema(implementation = Item.class, type = SchemaType.ARRAY)),
        responseCode = "200"
    )
)
public Response getItems(@Parameter(required = true) @QueryParam("page") @DefaultValue("1") int page) {
    return Response.ok(items.values()).build();
}
 
Example 19
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 20
Source Project: microprofile-open-api   Source File: BookingResource.java    License: Apache License 2.0 4 votes vote down vote up
@POST
@SecurityRequirement(
        name = "bookingSecurityScheme",
        scopes = {"write:bookings", "read:bookings"}
    )
@Callback(
    name = "bookingCallback",
    callbackUrlExpression = "http://localhost:9080/airlines/bookings",
    operations = @CallbackOperation(
        method ="get",
        summary="Retrieve all bookings for current user",
        responses={
            @APIResponse(
                responseCode="200",
                description="Bookings retrieved",
                [email protected](
                    mediaType="application/json",
                    [email protected](
                        type = SchemaType.ARRAY,
                        implementation=Booking.class))
            ),
            @APIResponse(
                responseCode="404",
                description="No bookings found for the user.")
        }))
@APIResponse(
        responseCode="201",
        description="Booking created",
        content = @Content(
            [email protected](
                name= "id",
                description = "id of the new booking",
                type=SchemaType.STRING
            )
        )
    )
@Operation(
    summary="Create a booking",
    description = "Create a new booking record with the booking information provided.",
    operationId = "createBooking"
)
@Consumes("application/json")
@Produces("application/json")
public Response createBooking(@RequestBody(
        description = "Create a new booking with the provided information.",
        content = @Content(
            mediaType = "application/json",
            schema = @Schema(ref="Booking"),
            examples = @ExampleObject(
                name = "booking",
                summary = "External booking example",
                externalValue = "http://foo.bar/examples/booking-example.json"
            )
        )) Booking task) {
        bookings.put(currentId, task);
        return Response.status(Status.CREATED).entity("{\"id\":" + currentId++ + "}").build();
    }
 
Example 21
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 22
Source Project: microprofile-open-api   Source File: ReviewResource.java    License: 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 23
@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 24
Source Project: microprofile-open-api   Source File: UserResource.java    License: 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 25
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();
        }
 
Example 26
Source Project: microprofile-open-api   Source File: UserResource.java    License: Apache License 2.0 4 votes vote down vote up
@PATCH
@Path("/{username}")
@APIResponse(
        responseCode = "200",
        description = "Password was changed successfully"
    )
@Operation(
    summary = "Change user password",
    description = "This changes the password for the logged in user.",
    operationId = "changePassword"
)
@SecurityRequirementsSet(
    value = {
        @SecurityRequirement(
            name = "userApiKey"
        ),
        @SecurityRequirement(
            name = "userBearerHttp"
        )
    }
)
public void changePassword(
    @Parameter(
        name = "username",
        description = "name that need to be deleted",
        schema = @Schema(type = SchemaType.STRING),
        required = true)
    @PathParam("username") String username,
    @Parameter(
        name = "currentPassword",
        description = "the user's current password",
        schema = @Schema(type = SchemaType.STRING),
        required = true)
    @QueryParam("currentPassword") String currentPassword,
    @Parameter(
        name = "newPassword",
        description = "the user's desired new password",
        schema = @Schema(type = SchemaType.STRING),
        required = true)
    @QueryParam("newPassword") String newPassword) {
        // don't do anything - this is just a TCK test
}
 
Example 27
Source Project: microprofile-open-api   Source File: UserResource.java    License: 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 28
Source Project: microprofile-open-api   Source File: UserResource.java    License: 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 29
Source Project: microprofile-open-api   Source File: PetStoreResource.java    License: 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");
    }
}
 
Example 30
Source Project: microprofile-open-api   Source File: PetResource.java    License: Apache License 2.0 4 votes vote down vote up
@GET
@Path("/{petId}")
@APIResponses(value={
        @APIResponse(
                responseCode = "400",
                description = "Invalid ID supplied",
                content = @Content(
                    mediaType = "none")
            ),
            @APIResponse(
                responseCode = "404",
                description = "Pet not found",
                content = @Content(
                    mediaType = "none")
            ),
            @APIResponse(
                responseCode = "200",
                content = @Content(
                    mediaType = "application/json",
                    schema = @Schema(type = SchemaType.OBJECT, implementation = Pet.class, 
                      oneOf = { Cat.class, Dog.class, Lizard.class }, 
                      readOnly = true))
            )
})
@Operation(
        summary = "Find pet by ID",
        description = "Returns a pet when ID is less than or equal to 10"
)
public Response getPetById(
    @Parameter(
        name = "petId",
        description = "ID of pet that needs to be fetched",
        required = true,
        example = "1",
        schema = @Schema(
            implementation = Long.class,
            maximum = "101",
            exclusiveMaximum = true,
            minimum = "9",
            exclusiveMinimum = true, 
            multipleOf = 10))
    @PathParam("petId") Long petId)
throws NotFoundException {
    Pet pet = petData.getPetById(petId);
    if (pet != null) {
        return Response.ok().entity(pet).build();
    }
    else {
        throw new NotFoundException(404, "Pet not found");
    }
}