Java Code Examples for org.eclipse.microprofile.openapi.annotations.Operation

The following examples show how to use org.eclipse.microprofile.openapi.annotations.Operation. 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: component-runtime   Source File: ComponentResource.java    License: Apache License 2.0 7 votes vote down vote up
@POST
@Path("migrate/{id}/{configurationVersion}")
@Operation(operationId = "migrateComponent",
        description = "Allows to migrate a component configuration without calling any component execution.")
@APIResponse(responseCode = "200",
        description = "the new configuration for that component (or the same if no migration was needed).",
        content = @Content(mediaType = APPLICATION_JSON))
@APIResponse(responseCode = "404", description = "The component is not found",
        content = @Content(mediaType = APPLICATION_JSON,
                schema = @Schema(type = OBJECT, implementation = ErrorPayload.class)))
Map<String, String> migrate(
        @PathParam("id") @Parameter(name = "id", description = "the component identifier", in = PATH) String id,
        @PathParam("configurationVersion") @Parameter(name = "configurationVersion",
                description = "the configuration version you send", in = PATH) int version,
        @RequestBody(description = "the actual configuration in key/value form.", required = true,
                content = @Content(mediaType = APPLICATION_JSON,
                        schema = @Schema(type = OBJECT))) Map<String, String> config);
 
Example 2
Source Project: quarkus-in-prod   Source File: LegumeApi.java    License: Apache License 2.0 6 votes vote down vote up
@POST
@Path("/init")
@Operation(
        operationId = "ProvisionLegumes",
        summary = "Add default legumes to the Database"
)
@APIResponse(
        responseCode = "201",
        description = "Default legumes created"
)
@APIResponse(
        name = "notFound",
        responseCode = "404",
        description = "Legume provision not found"
)
@APIResponse(
        name = "internalError",
        responseCode = "500",
        description = "Internal Server Error"
)
Response provision();
 
Example 3
Source Project: quarkus-in-prod   Source File: LegumeApi.java    License: Apache License 2.0 6 votes vote down vote up
@Operation(
        operationId = "ListLegumes",
        summary = "List all legumes"
)
@APIResponse(
        responseCode = "200",
        description = "The List with all legumes"
)
@APIResponse(
        name = "notFound",
        responseCode = "404",
        description = "Legume list not found"
)
@APIResponse(
        name = "internalError",
        responseCode = "500",
        description = "Internal Server Error"
)
@GET
List<Legume> list();
 
Example 4
@APIResponses(
        value = {
            @APIResponse(
                    responseCode = "404",
                    description = "We could not find anything",
                    content = @Content(mediaType = "text/plain"))
            ,
    @APIResponse(
                    responseCode = "200",
                    description = "We have a list of books",
                    content = @Content(mediaType = "application/json",
                            schema = @Schema(implementation = Properties.class)))})
@Operation(summary = "Outputs a list of books",
        description = "This method outputs a list of books")
@Timed(name = "get-all-books",
        description = "Monitor the time getAll Method takes",
        unit = MetricUnits.MILLISECONDS,
        absolute = true)
@GET
public Response getAll() {
    return Response.ok(bookService.getAll()).build();
}
 
Example 5
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 6
Source Project: microprofile-open-api   Source File: BookingResource.java    License: Apache License 2.0 6 votes vote down vote up
@PUT
@Path("{id}")
@Consumes("application/json")
@Produces("text/plain")
@APIResponse(
        responseCode="200",
        description="Booking updated"
        )
@APIResponse(
        responseCode="404",
        description="Booking not found"
        )
@Operation(
    summary="Update a booking with ID",
    operationId = "updateBookingId")
public Response updateBooking(
    @PathParam("id") int id, Booking booking){
        if(bookings.get(id)!=null){
            bookings.put(id, booking);
            return Response.ok().build();
        }
        else{
            return Response.status(Status.NOT_FOUND).build();
        }
    }
 
Example 7
Source Project: microprofile-open-api   Source File: BookingResource.java    License: 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 8
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 9
Source Project: microprofile-open-api   Source File: ReviewResource.java    License: Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("{id}")
@APIResponse(
        responseCode="200",
        description="Review deleted"
        )
@APIResponse(
        responseCode="404",
        description="Review not found"
        )
@Operation(
    summary="Delete a Review with ID",
    operationId = "deleteReview"
    )
@Produces("text/plain")
public Response deleteReview(
        @PathParam("id") int id){
            if(reviews.get(id)!=null) {
                reviews.remove(id);
                return Response.ok().build();
            }
            else {
                return Response.status(Status.NOT_FOUND).build();
            }
        }
 
Example 10
Source Project: microprofile-open-api   Source File: UserResource.java    License: Apache License 2.0 6 votes vote down vote up
@GET
@Path("/logout")
@APIResponse(
            responseCode = "200",
            description = "Successful user logout."
            )
@ExternalDocumentation(
        description = "Policy on user security.",
        url = "http://exampleurl.com/policy"
        )
@Operation(
    summary = "Logs out current logged in user session",
    operationId = "logOutUser"
    /* tags = {"user"}, // intentionally removed to have a method with no tags */)
public Response logoutUser() {
return Response.ok().entity("").build();
}
 
Example 11
Source Project: microprofile-open-api   Source File: PetStoreResource.java    License: Apache License 2.0 6 votes vote down vote up
@POST
@Path("/order")
@Operation(
    summary = "Place an order for a pet"
)
@APIResponse(
        responseCode = "200", 
        description = "successful operation"
    )
@APIResponse(
        responseCode = "400", 
        description = "Invalid Order"
        ) 
public Order placeOrder(
    @Parameter(
        description = "order placed for purchasing the pet",
        required = true
    ) 
    Order order) {
        storeData.placeOrder(order);
        return storeData.placeOrder(order);
    }
 
Example 12
Source Project: microprofile-open-api   Source File: UserResource.java    License: Apache License 2.0 6 votes vote down vote up
@POST
@Path("/createWithArray")
@APIResponse(
        description = "successful operation"
    )
@Operation(
    summary = "Creates list of users with given input array"
)
public Response createUsersWithArrayInput(
    @Parameter(
        description = "List of user object",
        required = true
        ) User[] users) {
            for (User user : users) {
                userData.addUser(user);
        }
    return Response.ok().entity("").build();
}
 
Example 13
Source Project: microprofile-open-api   Source File: UserResource.java    License: Apache License 2.0 6 votes vote down vote up
@POST
@Path("/createWithList")
@APIResponse(
        description = "successful operation"
    )
@Operation(
    summary = "Creates list of users with given input array"
)
public Response createUsersWithListInput(
    @Parameter(
        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 14
Source Project: component-runtime   Source File: ComponentResource.java    License: Apache License 2.0 6 votes vote down vote up
@GET
@Path("index")
@Operation(operationId = "getComponentIndex", description = "Returns the list of available components.")
@APIResponse(responseCode = "200", description = "The index of available components.",
        content = @Content(mediaType = APPLICATION_OCTET_STREAM))
ComponentIndices getIndex(
        @QueryParam("language") @DefaultValue("en") @Parameter(name = "language",
                description = "the language for display names.", in = QUERY,
                schema = @Schema(type = STRING, defaultValue = "en")) String language,
        @QueryParam("includeIconContent") @DefaultValue("false") @Parameter(name = "includeIconContent",
                description = "should the icon binary format be included in the payload.", in = QUERY,
                schema = @Schema(type = STRING, defaultValue = "en")) boolean includeIconContent,
        @QueryParam("q") @Parameter(name = "q",
                description = "Query in simple query language to filter components. "
                        + "It provides access to the component `plugin`, `name`, `id` and `metadata` of the first configuration property. "
                        + "Ex: `(id = AYETAE658349453) AND (metadata[configurationtype::type] = dataset) AND (plugin = jdbc-component) AND "
                        + "(name = input)`",
                in = QUERY, schema = @Schema(type = STRING)) String query);
 
Example 15
@GET
@Path("index")
@Operation(description = "Returns all available configuration type - storable models. "
        + "Note that the lightPayload flag allows to load all of them at once when you eagerly need "
        + " to create a client model for all configurations.")
@APIResponse(responseCode = "200",
        description = "the list of available and storable configurations (datastore, dataset, ...).",
        content = @Content(mediaType = APPLICATION_JSON))
ConfigTypeNodes getRepositoryModel(
        @QueryParam("language") @DefaultValue("en") @Parameter(name = "language",
                description = "the language for display names.", in = QUERY,
                schema = @Schema(type = STRING, defaultValue = "en")) String language,
        @QueryParam("lightPayload") @DefaultValue("true") @Parameter(name = "lightPayload",
                description = "should the payload skip the forms and actions associated to the configuration.",
                in = QUERY, schema = @Schema(type = BOOLEAN, defaultValue = "true")) boolean lightPayload,
        @QueryParam("q") @Parameter(name = "q",
                description = "Query in simple query language to filter configurations. "
                        + "It provides access to the configuration `type`, `name`, `type` and "
                        + "first configuration property `metadata`. "
                        + "See component index endpoint for a syntax example.",
                in = QUERY, schema = @Schema(type = STRING)) String query);
 
Example 16
@POST
@Path("migrate/{id}/{configurationVersion}")
@Operation(operationId = "migrateConfiguration",
        description = "Allows to migrate a configuration without calling any component execution.")
@APIResponse(responseCode = "200",
        description = "the new values for that configuration (or the same if no migration was needed).",
        content = @Content(mediaType = APPLICATION_JSON))
@APIResponse(responseCode = "400",
        description = "If the configuration is missing, payload will be an ErrorPayload with the code CONFIGURATION_MISSING.",
        content = @Content(mediaType = APPLICATION_JSON,
                schema = @Schema(type = OBJECT, implementation = ErrorPayload.class)))
@APIResponse(responseCode = "404", description = "The configuration is not found",
        content = @Content(mediaType = APPLICATION_JSON))
Map<String, String> migrate(
        @PathParam("id") @Parameter(name = "id", description = "the configuration identifier", in = PATH) String id,
        @PathParam("configurationVersion") @Parameter(name = "configurationVersion",
                description = "the configuration version you send", in = PATH) int version,
        @RequestBody(description = "the actual configuration in key/value form.", required = true,
                content = @Content(mediaType = APPLICATION_JSON,
                        schema = @Schema(type = OBJECT))) Map<String, String> config);
 
Example 17
Source Project: component-runtime   Source File: DocumentationResource.java    License: Apache License 2.0 6 votes vote down vote up
@GET
@Path("component/{id}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(
        description = "Returns an asciidoctor version of the documentation for the component represented by its identifier `id`.")
@APIResponse(responseCode = "200",
        description = "the list of available and storable configurations (datastore, dataset, ...).",
        content = @Content(mediaType = APPLICATION_JSON))
@APIResponse(responseCode = "404",
        description = "If the component is missing, payload will be an ErrorPayload with the code PLUGIN_MISSING.",
        content = @Content(mediaType = APPLICATION_JSON,
                schema = @Schema(type = OBJECT, implementation = ErrorPayload.class)))
DocumentationContent getDocumentation(
        @PathParam("id") @Parameter(name = "id", description = "the component identifier", in = PATH) String id,
        @QueryParam("language") @DefaultValue("en") @Parameter(name = "language",
                description = "the language for display names.", in = QUERY,
                schema = @Schema(type = STRING, defaultValue = "en")) String language,
        @QueryParam("segment") @DefaultValue("ALL") @Parameter(name = "segment",
                description = "the part of the documentation to extract.", in = QUERY,
                schema = @Schema(type = STRING, defaultValue = "ALL")) DocumentationSegment segment);
 
Example 18
@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 19
Source Project: quarkus-in-prod   Source File: LegumeApi.java    License: Apache License 2.0 5 votes vote down vote up
@POST
@Operation(
        operationId = "AddLegume",
        summary = "Add a Legume"
)
@RequestBody(
        content = @Content(
                mediaType = APPLICATION_JSON,
                schema = @Schema(implementation = LegumeNew.class, ref = "legume_new")),
        description = "The Legume to create",
        required = true
)
@APIResponse(
        responseCode = "201",
        description = "Legume created",
        content = @Content(
                mediaType = APPLICATION_JSON,
                schema = @Schema(implementation = Legume.class, ref = "error"))
)
@APIResponse(
        name = "notFound",
        responseCode = "400",
        description = "Legume data is invalid"
)
@APIResponse(
        name = "notFound",
        responseCode = "404",
        description = "Legume provision not found"
)
@APIResponse(
        name = "internalError",
        responseCode = "500",
        description = "Internal Server Error"
)
public Response add(@Valid final LegumeNew legume);
 
Example 20
Source Project: quarkus-in-prod   Source File: LegumeApi.java    License: Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("{id}")
@Operation(
        operationId = "DeleteLegume",
        summary = "Delete a Legume"
)
@APIResponse(
        responseCode = "204",
        description = "Empty response"
)
@APIResponse(
        name = "notFound",
        responseCode = "404",
        description = "Legume not found"
)
@APIResponse(
        name = "internalError",
        responseCode = "500",
        description = "Internal Server Error"
)
Response delete(
        @Parameter(name = "id",
                description = "Id of the Legume to delete",
                required = true,
                example = "81471222-5798-11e9-ae24-57fa13b361e1",
                schema = @Schema(description = "uuid", required = true))
        @PathParam("id")
        @NotEmpty final String legumeId);
 
Example 21
@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 22
@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 23
Source Project: smallrye-open-api   Source File: ParameterScanTests.java    License: Apache License 2.0 5 votes vote down vote up
@POST
@Path("/widgets/create")
@Consumes(MediaType.APPLICATION_JSON)
@Operation(operationId = "createWidget")
public void createWidget(
        @RequestBody(required = true, content = @Content(schema = @Schema(implementation = Widget.class))) final Widget w) {
}
 
Example 24
@Path("{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Returns an AbstractPet with a discriminator declared in the response")
@APIResponse(content = {
        @Content(schema = @Schema(oneOf = { Cat.class, Dog.class,
                Lizard.class }, discriminatorProperty = "pet_type", discriminatorMapping = {
                        @DiscriminatorMapping(value = "dog", schema = Dog.class)
                }))
})
@SuppressWarnings("unused")
public AbstractPet get(@PathParam("id") String id) {
    return null;
}
 
Example 25
@Path("{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Returns an AbstractPet with only a discriminator property declared in the response, "
        + "no Dogs allowed!")
@APIResponse(content = {
        @Content(schema = @Schema(oneOf = { Cat.class, Lizard.class }, discriminatorProperty = "pet_type"))
})
@SuppressWarnings("unused")
public AbstractPet get(@PathParam("id") String id) {
    return null;
}
 
Example 26
@Path("{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Returns an AbstractPet with a discriminator declared in the response, "
        + "no mapping due to undeclared mapping schema")
@APIResponse(content = {
        @Content(schema = @Schema(oneOf = { Cat.class, Dog.class,
                Lizard.class }, discriminatorProperty = "pet_type", discriminatorMapping = {
                        @DiscriminatorMapping(value = "dog") }))
})
@SuppressWarnings("unused")
public AbstractPet get(@PathParam("id") String id) {
    return null;
}
 
Example 27
@Path("{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Returns an AbstractPet with a discriminator declared in the response, "
        + "mapping with default (implied) key")
@APIResponse(content = {
        @Content(schema = @Schema(oneOf = { Cat.class, Dog.class,
                Lizard.class }, discriminatorProperty = "pet_type", discriminatorMapping = {
                        @DiscriminatorMapping(schema = Dog.class) }))
})
@SuppressWarnings("unused")
public AbstractPet get(@PathParam("id") String id) {
    return null;
}
 
Example 28
@Path("{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Returns an AbstractPet with a discriminator declared in the response, "
        + "no mapping due to empty @DiscriminatorMapping")
@APIResponse(content = {
        @Content(schema = @Schema(oneOf = { Cat.class, Dog.class,
                Lizard.class }, discriminatorProperty = "pet_type", discriminatorMapping = { @DiscriminatorMapping }))
})
@SuppressWarnings("unused")
public AbstractPet get(@PathParam("id") String id) {
    return null;
}
 
Example 29
@Path("{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Returns an AbstractPet with a discriminator declared in the response, "
        + "no property name (invalid OpenAPI document)")
@APIResponse(content = {
        @Content(schema = @Schema(oneOf = { Cat.class, Dog.class, Lizard.class }, discriminatorMapping = {
                @DiscriminatorMapping(value = "dog", schema = Dog.class) }))
})
@SuppressWarnings("unused")
public AbstractPet get(@PathParam("id") String id) {
    return null;
}
 
Example 30
Source Project: smallrye-open-api   Source File: ResourceParameterTests.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Operation(summary = "Get an object containing a primitive array")
@APIResponses({
        @APIResponse(responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = PrimitiveArrayTestObject.class))) })
public PrimitiveArrayTestObject getResponse() {
    return new PrimitiveArrayTestObject();
}