org.eclipse.microprofile.openapi.annotations.media.Schema Java Examples
The following examples show how to use
org.eclipse.microprofile.openapi.annotations.media.Schema.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ComponentResource.java From component-runtime with Apache License 2.0 | 7 votes |
@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 File: ConfigurationTypeResource.java From component-runtime with Apache License 2.0 | 6 votes |
@GET @Path("details") @Operation(operationId = "getConfigurationDetail", 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 getDetail( @QueryParam("language") @DefaultValue("en") @Parameter(name = "language", description = "the language for display names.", in = QUERY, schema = @Schema(type = STRING, defaultValue = "en")) String language, @QueryParam("identifiers") @Parameter(name = "identifiers", description = "the comma separated list of identifiers to request.", in = QUERY) String[] ids);
Example #3
Source File: ExtensionParsingTests.java From smallrye-open-api with Apache License 2.0 | 6 votes |
@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 #4
Source File: ComponentResource.java From component-runtime with Apache License 2.0 | 6 votes |
@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 #5
Source File: DocumentationResource.java From component-runtime with Apache License 2.0 | 6 votes |
@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 #6
Source File: BookingResource.java From microprofile-open-api with Apache License 2.0 | 6 votes |
@GET @Tag(ref="bookings") @APIResponses(value={ @APIResponse( responseCode="200", description="Bookings retrieved", content=@Content( schema=@Schema( type = SchemaType.ARRAY, implementation=Booking.class)) ), @APIResponse( responseCode="404", description="No bookings found for the user.") }) @Operation( summary="Retrieve all bookings for current user", operationId = "getAllBookings") @Produces("application/json") public Response getBookings(){ return Response.ok().entity(bookings.values()).build(); }
Example #7
Source File: ReviewResource.java From microprofile-open-api with Apache License 2.0 | 6 votes |
@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 #8
Source File: NotFoundExceptionMapper.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@Override @APIResponse(responseCode = "404", description = "Not Found", content = @Content( schema = @Schema(implementation = User.class) ) ) public Response toResponse(NotFoundException t) { return Response.status(404, t.getMessage()).build(); }
Example #9
Source File: UserResource.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@POST @APIResponse( description = "successful operation" ) @Operation( summary = "Create user", description = "This can only be done by the logged in user." ) @SecurityRequirements( value = { @SecurityRequirement( name = "userApiKey" ), @SecurityRequirement( name = "userBasicHttp" ), @SecurityRequirement( name = "userBearerHttp" ) } ) public Response createUser( @Parameter( description = "Created user object", schema = @Schema(ref = "#/components/schemas/User"), required = true ) User user) { userData.addUser(user); return Response.ok().entity("").build(); }
Example #10
Source File: PetResource.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@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 #11
Source File: PetResource.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@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 #12
Source File: PetStoreResource.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@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 #13
Source File: ActionResource.java From component-runtime with Apache License 2.0 | 5 votes |
@GET @Path("index") @Operation(operationId = "getActionIndex", description = "This endpoint returns the list of available actions for a certain family and potentially filters the " + "output limiting it to some families and types of actions.") @APIResponse(responseCode = "200", description = "The action index.", content = @Content(mediaType = APPLICATION_JSON)) ActionList getIndex( @QueryParam("type") @Parameter(name = "type", in = QUERY, description = "the types of actions") String[] types, @QueryParam("family") @Parameter(name = "family", in = QUERY, description = "the families") String[] families, @QueryParam("language") @Parameter(name = "language", description = "the language to use", in = QUERY, schema = @Schema(defaultValue = "en", type = STRING)) @DefaultValue("en") String language);
Example #14
Source File: BookingResource.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@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", content=@Content( schema=@Schema( 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 #15
Source File: UserResource.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@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 #16
Source File: Pet.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@XmlElement(name = "status") @Schema( name = "status", title = "pet status in the store"//, //_enum = {"available", "pending", "sold"} ) public String getStatus() { return status; }
Example #17
Source File: ComponentResource.java From component-runtime with Apache License 2.0 | 5 votes |
@GET @Path("details") // bulk mode to avoid to fetch components one by one when reloading a pipeline/job @Operation(operationId = "getComponentDetail", description = "Returns the set of metadata about a few components identified by their 'id'.") @APIResponse(responseCode = "200", description = "the list of details for the requested components.", content = @Content(mediaType = APPLICATION_JSON)) @APIResponse(responseCode = "400", description = "Some identifiers were not valid.", content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(type = OBJECT, implementation = SampleErrorForBulk.class))) ComponentDetailList getDetail( @QueryParam("language") @DefaultValue("en") @Parameter(name = "language", description = "the language for display names.", in = QUERY, schema = @Schema(type = STRING, defaultValue = "en")) String language, @QueryParam("identifiers") @Parameter(name = "identifiers", description = "the component identifiers to request.", in = QUERY) String[] ids);
Example #18
Source File: UserResource.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@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 #19
Source File: DiscriminatorMappingTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@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 #20
Source File: UserResource.java From microprofile-open-api with Apache License 2.0 | 5 votes |
@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 #21
Source File: CustomExtensionParsingTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@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 #22
Source File: ResourceParameterTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@POST @Consumes("application/json") @Produces("application/json") @Operation(summary = "Convert an array of integer types to an array of floating point types") @RequestBody(content = @Content(schema = @Schema(anyOf = { int[].class, long[].class }))) @APIResponses({ @APIResponse(responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(oneOf = { float[].class, double[].class }))) }) public Object intToFloat(@SuppressWarnings("unused") Object input) { return null; }
Example #23
Source File: ResourceParameterTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@POST @Consumes("application/json") @Produces("application/json") @Operation(summary = "Convert an array of doubles to an array of floats") @APIResponses({ @APIResponse(responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = float[].class))) }) public float[] doubleToFloat(@SuppressWarnings("unused") double[] input) { return new float[0]; }
Example #24
Source File: ResourceParameterTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@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(); }
Example #25
Source File: DiscriminatorMappingTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@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 #26
Source File: DiscriminatorMappingTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@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 #27
Source File: DiscriminatorMappingTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@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
Source File: DiscriminatorMappingTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@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 #29
Source File: DiscriminatorMappingTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@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 #30
Source File: LegumeApi.java From quarkus-in-prod with Apache License 2.0 | 5 votes |
@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);