org.eclipse.microprofile.openapi.annotations.media.Content Java Examples

The following examples show how to use org.eclipse.microprofile.openapi.annotations.media.Content. 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 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 File: Sample.java    From cxf with 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 #3
Source File: Sample.java    From cxf with 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 #4
Source File: ExtensionParsingTests.java    From smallrye-open-api with 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 #5
Source File: TestResource.java    From quarkus with 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 #6
Source File: BookingResource.java    From microprofile-open-api with Apache License 2.0 6 votes vote down vote up
@GET
@Tag(ref="bookings")
@APIResponses(value={
        @APIResponse(
                responseCode="200",
                description="Bookings retrieved",
                content=@Content(
                    schema=@Schema(
                        type = SchemaType.ARRAY,
                        implementation=Booking.class))
                ),
            @APIResponse(
                responseCode="404",
                description="No bookings found for the user.")
})
@Operation(
    summary="Retrieve all bookings for current user",
    operationId = "getAllBookings")
@Produces("application/json")
public Response getBookings(){
    return Response.ok().entity(bookings.values()).build();
}
 
Example #7
Source File: ReviewResource.java    From microprofile-open-api with 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 #8
Source File: ComponentResource.java    From component-runtime with 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 #9
Source File: ConfigurationTypeResource.java    From component-runtime with Apache License 2.0 6 votes vote down vote up
@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 #10
Source File: ConfigurationTypeResource.java    From component-runtime with Apache License 2.0 6 votes vote down vote up
@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 #11
Source File: DocumentationResource.java    From component-runtime with 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 #12
Source File: TrellisHttpResource.java    From trellis with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a GET operation on an LDP Resource.
 *
 * @implNote The Memento implemenation pattern exactly follows
 *           <a href="https://tools.ietf.org/html/rfc7089#section-4.2.1">section 4.2.1 of RFC 7089</a>.
 * @param uriInfo the URI info
 * @param headers the HTTP headers
 * @param request the request
 * @return the async response
 */
@GET
@Timed
@Operation(summary = "Get a linked data resource")
@APIResponses(
    value = {
        @APIResponse(
            responseCode = "404",
            description = "Missing resource"),
        @APIResponse(
            responseCode = "200",
            description = "The linked data resource, serialized as Turtle",
            content = @Content(mediaType = "text/turtle")),
        @APIResponse(
            responseCode = "200",
            description = "The linked data resource, serialized as JSON-LD",
            content = @Content(mediaType = "application/ld+json"))})
public CompletionStage<Response> getResource(@Context final Request request, @Context final UriInfo uriInfo,
        @Context final HttpHeaders headers) {
    return fetchResource(new TrellisRequest(request, uriInfo, headers))
        .thenApply(ResponseBuilder::build).exceptionally(this::handleException);
}
 
Example #13
Source File: TrellisHttpResource.java    From trellis with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a PATCH operation on an LDP Resource.
 *
 * @param uriInfo the URI info
 * @param secContext the security context
 * @param headers the HTTP headers
 * @param request the request
 * @param body the body
 * @return the async response
 */
@PATCH
@Timed
@Operation(summary = "Update a linked data resource")
public CompletionStage<Response> updateResource(@Context final Request request, @Context final UriInfo uriInfo,
        @Context final HttpHeaders headers, @Context final SecurityContext secContext,
        @RequestBody(description = "The update request for RDF resources, typically as SPARQL-Update",
                     required = true,
                     content = @Content(mediaType = "application/sparql-update")) final String body) {
    final TrellisRequest req = new TrellisRequest(request, uriInfo, headers, secContext);
    final String urlBase = getBaseUrl(req);
    final IRI identifier = buildTrellisIdentifier(req.getPath());
    final PatchHandler patchHandler = new PatchHandler(req, body, trellis, extensions, supportsCreateOnPatch,
            defaultJsonLdProfile, urlBase);

    return getParent(identifier).thenCombine(trellis.getResourceService().get(identifier), patchHandler::initialize)
        .thenCompose(patchHandler::updateResource).thenCompose(patchHandler::updateMemento)
        .thenApply(ResponseBuilder::build).exceptionally(this::handleException);
}
 
Example #14
Source File: Sample.java    From cxf with 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 #15
Source File: BookStoreEndpoint.java    From ebook-Building-an-API-Backend-with-MicroProfile with Apache License 2.0 6 votes vote down vote up
@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 #16
Source File: ConfigurationTypeResource.java    From component-runtime with Apache License 2.0 6 votes vote down vote up
@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 #17
Source File: Sample.java    From cxf with 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 #18
Source File: NestedSchemaOnParameterResource.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@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 #19
Source File: GetAuthor.java    From openshift-on-ibm-cloud-workshops with Apache License 2.0 5 votes vote down vote up
@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 #20
Source File: ComponentResource.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
@GET
@Path("dependency/{id}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Operation(description = "Return a binary of the dependency represented by `id`. "
        + "It can be maven coordinates for dependencies or a component id.")
@APIResponse(responseCode = "200", description = "The dependency binary (jar).",
        content = @Content(mediaType = APPLICATION_OCTET_STREAM))
@APIResponse(responseCode = "404",
        description = "If the plugin is missing, payload will be an ErrorPayload with the code PLUGIN_MISSING.",
        content = @Content(mediaType = APPLICATION_JSON,
                schema = @Schema(type = OBJECT, implementation = ErrorPayload.class)))
StreamingOutput getDependency(@PathParam("id") @Parameter(name = "id", description = "the dependency binary (jar).",
        in = PATH) String id);
 
Example #21
Source File: ComponentResource.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
@GET
@Path("dependencies")
@Operation(description = "Returns a list of dependencies for the given components. "
        + "IMPORTANT: don't forget to add the component itself since it will not be part of the dependencies."
        + "Then you can use /dependency/{id} to download the binary.")
@APIResponse(responseCode = "200", description = "The list of dependencies per component",
        content = @Content(mediaType = APPLICATION_JSON))
Dependencies getDependencies(@QueryParam("identifier") @Parameter(name = "identifier",
        description = "the list of component identifiers to find the dependencies for.", in = QUERY) String[] ids);
 
Example #22
Source File: UserResource.java    From microprofile-open-api with 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 #23
Source File: PetResource.java    From microprofile-open-api with 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 #24
Source File: PetResource.java    From microprofile-open-api with 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 #25
Source File: PetResource.java    From microprofile-open-api with Apache License 2.0 5 votes vote down vote up
@POST
@Consumes({"application/json", "application/xml"})
@Produces({"application/json", "application/xml"})
@SecurityRequirement(
        name = "petsApiKey"
    )
@APIResponse(
        responseCode = "400",
        description = "Invalid input",
        content = @Content(
            mediaType = "application/json",
            schema = @Schema(implementation = ApiResponse.class))
    )
@RequestBody(
        name="pet",
        content = @Content(
            mediaType = "application/json",
            schema = @Schema(implementation = Pet.class), 
            examples = @ExampleObject(ref = "http://example.org/petapi-examples/openapi.json#/components/examples/pet-example") ),
        required = true,
        description = "example of a new pet to add"
    )
@Operation(
    summary = "Add pet to store",
    description = "Add a new pet to the store"
)
public Response addPet(Pet pet) {
            Pet updatedPet = petData.addPet(pet);
            return Response.ok().entity(updatedPet).build();
        }
 
Example #26
Source File: NotFoundExceptionMapper.java    From microprofile-open-api with Apache License 2.0 5 votes vote down vote up
@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 #27
Source File: DiscriminatorMappingTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@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 #28
Source File: AirlinesResource.java    From microprofile-open-api with Apache License 2.0 5 votes vote down vote up
@GET
@APIResponse(
        ref = "FoundAirlines"
    )
@APIResponse(
        responseCode = "404",
        description = "No airlines found",
        content = @Content(
            mediaType = "n/a"
        )
    )
@Operation(
    summary = "Retrieve all available airlines",
    operationId = "getAirlines")
@Produces("application/json")
@Extensions({
    @Extension(name = "x-string-property", value = "string-value"),
    @Extension(name = "x-boolean-property", value = "true", parseValue = true),
    @Extension(name = "x-number-property", value = "117", parseValue = true),
    @Extension(
        name = "x-object-property", 
        value = "{ \"property-1\" : \"value-1\", \"property-2\" : \"value-2\", \"property-3\" : { \"prop-3-1\" : 17, \"prop-3-2\" : true } }", 
        parseValue = true),
    @Extension(name = "x-string-array-property", value = "[ \"one\", \"two\", \"three\" ]", parseValue = true),
    @Extension(name = "x-object-array-property", value = "[ { \"name\": \"item-1\" }, { \"name\" : \"item-2\" } ]", parseValue = true)
})
public Response getAirlines(){
    return Response.ok().entity(airlines.values()).build();
}
 
Example #29
Source File: BookingResource.java    From microprofile-open-api with 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",
                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 #30
Source File: ComponentResource.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
@GET
@Path("icon/family/{id}")
@Produces({ APPLICATION_JSON, APPLICATION_OCTET_STREAM })
@Operation(description = "Returns the icon for a family.")
@APIResponse(responseCode = "200", description = "Returns a particular family icon in raw bytes.",
        content = @Content(mediaType = APPLICATION_OCTET_STREAM))
@APIResponse(responseCode = "404", description = "The family or icon is not found",
        content = @Content(mediaType = APPLICATION_JSON,
                schema = @Schema(type = OBJECT, implementation = ErrorPayload.class)))
Response familyIcon(
        @PathParam("id") @Parameter(name = "id", description = "the family identifier", in = PATH) String id);