Java Code Examples for org.eclipse.microprofile.openapi.annotations.parameters.Parameter

The following examples show how to use org.eclipse.microprofile.openapi.annotations.parameters.Parameter. 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: 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 3
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 4
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 5
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 6
@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 7
@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 8
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 9
Source Project: cxf   Source File: Sample.java    License: Apache License 2.0 6 votes vote down vote up
@Produces({ MediaType.APPLICATION_JSON })
@Path("/{name}")
@GET
@Operation(
    summary = "Get item by name",
    description = "Get operation with type and headers"
)
@APIResponses({
    @APIResponse(content = @Content(schema = @Schema(implementation = Item.class)), responseCode = "200"),
    @APIResponse(responseCode = "404")
})
public Response getItem(
        @Parameter(required = true) @HeaderParam("Accept-Language") final String language,
        @Parameter(required = true) @PathParam("name") String name) {
    return items.containsKey(name) 
        ? Response.ok().entity(items.get(name)).build() 
            : Response.status(Status.NOT_FOUND).build();
}
 
Example 10
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 11
Source Project: cxf   Source File: Sample.java    License: Apache License 2.0 6 votes vote down vote up
@Produces({ MediaType.APPLICATION_JSON })
@Path("/{name}")
@PUT
@Operation(
    summary = "Update an existing new item",
    description = "Put operation with form parameter"
)
@APIResponse(
    content = @Content(schema = @Schema(implementation = Item.class)),
    responseCode = "200"
)
public Item updateItem(
        @Parameter(required = true) @PathParam("name") String name,
        @Parameter(required = true) @FormParam("value") String value) {
    Item item = new Item(name, value);
    items.put(name,  item);
    return item;
}
 
Example 12
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 13
@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 14
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 15
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 16
@SuppressWarnings("unused")
@POST
@Produces(MediaType.APPLICATION_JSON)
@APIResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = NestedParameterTestParent.class)))
public NestedParameterTestParent getHiddenResponse(
        @Parameter(name = "arg", in = ParameterIn.COOKIE) NestedParameterTestParent request) {
    return new NestedParameterTestParent();
}
 
Example 17
Source Project: smallrye-open-api   Source File: ParameterScanTests.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("unused")
@Parameter(name = "X-Custom-Header", in = ParameterIn.HEADER, required = true)
@Parameter(name = "id", in = ParameterIn.PATH)
public Widget get(@HeaderParam("X-Custom-Header") String custom,
        @PathParam("id") @DefaultValue("000") String id) {
    return null;
}
 
Example 18
Source Project: smallrye-open-api   Source File: ParameterScanTests.java    License: Apache License 2.0 5 votes vote down vote up
public ParametersInConstructorTestResource(
        @Parameter(name = "h1", in = ParameterIn.HEADER, description = "Description of h1") @HeaderParam("h1") @Deprecated String h1,
        @Parameter(name = "h2", in = ParameterIn.HEADER, hidden = true) @HeaderParam("h2") String h2,
        @Parameter(name = "q1", deprecated = true) @QueryParam("q1") String q1,
        @NotNull @CookieParam("c1") String c1,
        @PathParam("p1") String p1,
        @BeanParam Bean b1) {
}
 
Example 19
Source Project: smallrye-open-api   Source File: ParameterScanTests.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
@Parameter(name = "id", in = ParameterIn.PATH, style = ParameterStyle.MATRIX, description = "Additional information for id2")
public Widget get(@MatrixParam("m1") @DefaultValue("default-m1") String m1,
        @MatrixParam("m2") @Size(min = 20) String m2) {
    return null;
}
 
Example 20
Source Project: smallrye-open-api   Source File: ParameterScanTests.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("/seg1/seg2/resourceA")
@Produces(MediaType.APPLICATION_JSON)
@Parameter(in = ParameterIn.PATH, name = "resourceA", style = ParameterStyle.MATRIX)
public Widget get(@MatrixParam("m1") @DefaultValue("default-m1") int m1,
        @MatrixParam("m2") @DefaultValue("100") @Max(200) int m2) {
    return null;
}
 
Example 21
Source Project: smallrye-open-api   Source File: ParameterScanTests.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("seg1")
@Produces(MediaType.TEXT_PLAIN)
@Parameter(name = "segments", description = "Test", style = ParameterStyle.MATRIX, in = ParameterIn.PATH)
public String echo(@PathParam("segments") PathSegment segmentsMatrix) {
    return segmentsMatrix.getPath();
}
 
Example 22
Source Project: smallrye-open-api   Source File: ParameterScanTests.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("{p1}")
@Produces(MediaType.TEXT_PLAIN)
public String echo(
        @Parameter(name = "Path1", in = ParameterIn.PATH, style = ParameterStyle.SIMPLE, description = "The name 'Path1' will not be used instead of 'p1'") @PathParam("p1") String p1) {
    return p1;
}
 
Example 23
Source Project: smallrye-open-api   Source File: SubresourceScanTests.java    License: Apache License 2.0 5 votes vote down vote up
@Path("/sub/{id}")
@Parameter(name = "id", description = "Resource Identifier")
public Sub1TestResource get(@PathParam("id") String id,
        @QueryParam("q1") String q1,
        @MatrixParam("m1") String m1,
        @MatrixParam("m2") int m2,
        @FormParam("f1") String f1) {
    return null;
}
 
Example 24
Source Project: javaee8-cookbook   Source File: ContactResource.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("/contact/{id}")
@APIResponse(responseCode = "200",
        description = "Single contact response",
        name = "SingleContactResponse"
)
@Parameter(name = "id",
        description = "Contact Id",
        required = true,
        allowEmptyValue = false
)
public Response getContactById(@PathParam("id") Long id) {
    return Response.ok("This is a single contact").build();
}
 
Example 25
Source Project: microprofile-open-api   Source File: BookingResource.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("{id}")
@Parameters(
    {
        @Parameter(
                    name = "id",
                    description = "ID of the booking",
                    required = true,
                    in = ParameterIn.PATH,
                    style = ParameterStyle.SIMPLE
                )
        }
        )

@Produces("application/json")
@Operation(
    summary="Get a booking with ID",
    operationId = "getBookingById")
@APIResponses(value={
        @APIResponse(
                responseCode="200",
                description="Booking retrieved",
                [email protected](
                    [email protected](
                        implementation=Booking.class))),
        @APIResponse(
                responseCode="404",
                description="Booking not found")
})
public Response getBooking(
    @PathParam("id") int id){
        Booking booking = bookings.get(id);
        if(booking!=null){
            return Response.ok().entity(booking).build();
        }
        else{
            return Response.status(Status.NOT_FOUND).build();
        }
    }
 
Example 26
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 27
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 28
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 29
Source Project: microprofile-open-api   Source File: PetResource.java    License: Apache License 2.0 5 votes vote down vote up
@PUT
@Consumes({"application/json", "application/xml"})
@SecurityRequirement(
        name = "petsHttp"
    )
@APIResponses(value={
        @APIResponse(
                responseCode = "400",
                description = "Invalid ID supplied",
                content = @Content(mediaType = "application/json")
            ),
            @APIResponse(
                responseCode = "404",
                description = "Pet not found",
                content = @Content(mediaType = "application/json")
            ),
            @APIResponse(
                responseCode = "405",
                description = "Validation exception",
                content = @Content(mediaType = "application/json")
            )
})
@Operation(
    summary = "Update an existing pet",
    description = "Update an existing pet with the given new attributes"
)
public Response updatePet(
    @Parameter(
        name ="petAttribute",
        description = "Attribute to update existing pet record",
        required = true,
        schema = @Schema(implementation = Pet.class)) Pet pet) {
            Pet updatedPet = petData.addPet(pet);
            return Response.ok().entity(updatedPet).build();
        }
 
Example 30
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();
    }