io.swagger.v3.oas.annotations.media.ArraySchema Java Examples
The following examples show how to use
io.swagger.v3.oas.annotations.media.ArraySchema.
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: Swagger2Module.java From jsonschema-generator with Apache License 2.0 | 7 votes |
/** * Look up a value from a {@link Schema} annotation on the given property or its associated field/getter or an external class referenced by * {@link Schema#implementation()}. * * @param member field/method for which to look-up any present {@link Schema} annotation * @param valueExtractor the getter for the value from the annotation * @param valueFilter filter that determines whether the value from a given annotation matches our criteria * @param <T> the type of the returned value * * @return the value from one of the matching {@link Schema} annotations or {@code Optional.empty()} */ private <T> Optional<T> getSchemaAnnotationValue(MemberScope<?, ?> member, Function<Schema, T> valueExtractor, Predicate<T> valueFilter) { if (member.isFakeContainerItemScope()) { return this.getArraySchemaAnnotation(member) .map(ArraySchema::schema) .map(valueExtractor) .filter(valueFilter); } Schema annotation = member.getAnnotationConsideringFieldAndGetter(Schema.class); if (annotation != null) { return Optional.of(annotation) .map(valueExtractor) .filter(valueFilter); } return this.getArraySchemaAnnotation(member) .map(ArraySchema::arraySchema) .map(valueExtractor) .filter(valueFilter); }
Example #2
Source File: QuoteRouter.java From springdoc-openapi with Apache License 2.0 | 6 votes |
@RouterOperations({ @RouterOperation(path = "/hello", operation = @Operation(operationId = "hello", responses = @ApiResponse(responseCode = "200"))), @RouterOperation(path = "/echo", produces = TEXT_PLAIN_VALUE, operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))), responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))), @RouterOperation(path = "/echo",produces = APPLICATION_JSON_VALUE, operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))), responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))), @RouterOperation(path = "/quotes", produces = APPLICATION_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes", parameters = @Parameter(name = "size", in = ParameterIn.QUERY, schema = @Schema(type = "string")), responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Quote.class)))))), @RouterOperation(path = "/quotes", produces = APPLICATION_STREAM_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes", responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Quote.class))))) }) @Bean public RouterFunction<ServerResponse> route(QuoteHandler quoteHandler) { return RouterFunctions .route(GET("/hello").and(accept(TEXT_PLAIN)), quoteHandler::hello) .andRoute(POST("/echo").and(accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN))), quoteHandler::echo) .andRoute(POST("/echo").and(accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON))), quoteHandler::echo) .andRoute(GET("/quotes").and(accept(APPLICATION_JSON)), quoteHandler::fetchQuotes) .andRoute(GET("/quotes").and(accept(APPLICATION_STREAM_JSON)), quoteHandler::streamQuotes); }
Example #3
Source File: FunctionsResource.java From cantor with BSD 3-Clause "New" or "Revised" License | 6 votes |
@DELETE @Path("/run/{namespace}/{function}") @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Execute delete method on function query") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Process and execute the function", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))), @ApiResponse(responseCode = "500", description = serverErrorMessage) }) public Response deleteExecuteFunction(@PathParam("namespace") final String namespace, @PathParam("function") final String function, @Context final HttpServletRequest request, @Context final HttpServletResponse response) { logger.info("executing '{}/{}' with delete method", namespace, function); return doExecute(namespace, function, request, response); }
Example #4
Source File: FunctionsResource.java From cantor with BSD 3-Clause "New" or "Revised" License | 6 votes |
@POST @Path("/run/{namespace}/{function}") @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Execute post method on function query") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Process and execute the function", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))), @ApiResponse(responseCode = "500", description = serverErrorMessage) }) public Response postExecuteFunction(@PathParam("namespace") final String namespace, @PathParam("function") final String function, @Context final HttpServletRequest request, @Context final HttpServletResponse response) { logger.info("executing '{}/{}' with post method", namespace, function); return doExecute(namespace, function, request, response); }
Example #5
Source File: FunctionsResource.java From cantor with BSD 3-Clause "New" or "Revised" License | 6 votes |
@PUT @Path("/run/{namespace}/{function}") @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Execute put method on function query") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Process and execute the function", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))), @ApiResponse(responseCode = "500", description = serverErrorMessage) }) public Response putExecuteFunction(@PathParam("namespace") final String namespace, @PathParam("function") final String function, @Context final HttpServletRequest request, @Context final HttpServletResponse response) { logger.info("executing '{}/{}' with put method", namespace, function); return doExecute(namespace, function, request, response); }
Example #6
Source File: FunctionsResource.java From cantor with BSD 3-Clause "New" or "Revised" License | 6 votes |
@GET @Path("/run/{namespace}/{function}") @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Execute 'get' method on a function") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Process and execute the function", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))), @ApiResponse(responseCode = "500", description = serverErrorMessage) }) public Response getExecuteFunction(@PathParam("namespace") final String namespace, @PathParam("function") final String function, @Context final HttpServletRequest request, @Context final HttpServletResponse response) { logger.info("executing '{}/{}' with get method", namespace, function); return doExecute(namespace, function, request, response); }
Example #7
Source File: FunctionsResource.java From cantor with BSD 3-Clause "New" or "Revised" License | 6 votes |
@GET @Path("/{namespace}/{function}") @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Get a function") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Provides the function with the given name", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))), @ApiResponse(responseCode = "500", description = serverErrorMessage) }) public Response getFunction(@PathParam("namespace") final String namespace, @PathParam("function") final String functionName) throws IOException { final byte[] bytes = this.functions.get(namespace, functionName); if (bytes == null) { return Response.status(Response.Status.NOT_FOUND).build(); } return Response.ok(bytes).build(); }
Example #8
Source File: EventsResource.java From cantor with BSD 3-Clause "New" or "Revised" License | 6 votes |
@GET @Path("/{namespace}/metadata/{metadata}") @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Get all values for a metadata") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Provides the set of values the given metadata has been, matching query parameters", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))), @ApiResponse(responseCode = "400", description = "One of the query parameters has a bad value"), @ApiResponse(responseCode = "500", description = serverErrorMessage) }) public Response getMetadata(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace, @Parameter(description = "Specific metadata to search") @PathParam("metadata") final String metadata, @BeanParam final EventsDataSourceBean bean) throws IOException { logger.info("received request for metadata {} in namespace {}", metadata, namespace); logger.debug("request parameters: {}", bean); final Set<String> metadataValueSet = this.cantor.events().metadata( namespace, metadata, bean.getStart(), bean.getEnd(), bean.getMetadataQuery(), bean.getDimensionQuery() ); return Response.ok(parser.toJson(metadataValueSet)).build(); }
Example #9
Source File: EntriesProxyResource.java From browserup-proxy with Apache License 2.0 | 6 votes |
@GET @Produces(MediaType.APPLICATION_JSON) @Operation( description = "Search the entire log for entries whose request URL matches the given url", responses = {@ApiResponse(description = "Array of Har Entries", content = @Content( mediaType = MediaType.APPLICATION_JSON, array = @ArraySchema(schema = @Schema(implementation = HarEntry.class))))}) public Collection<HarEntry> entries( @PathParam(PORT) @NotNullConstraint(paramName = PORT) @PortWithExistingProxyConstraint @Parameter(required = true, in = ParameterIn.PATH, description = DocConstants.PORT_DESCRIPTION) int port, @QueryParam(URL_PATTERN) @NotBlankConstraint(paramName = URL_PATTERN) @PatternConstraint(paramName = URL_PATTERN) @Parameter(required = true, description = DocConstants.URL_PATTERN_DESCRIPTION) String urlPattern) { return proxyManager.get(port).findEntries(Pattern.compile(urlPattern)); }
Example #10
Source File: PostRouter.java From springdoc-openapi with Apache License 2.0 | 6 votes |
@RouterOperations({ @RouterOperation(path = "/posts", method = RequestMethod.GET, headers = {"x-header1=test1","x-header2=test2"}, operation = @Operation(operationId = "all", parameters = { @Parameter(name = "key", description = "sample description"),@Parameter(name = "test", description = "sample desc")}, responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Post.class)))))), @RouterOperation(path = "/posts", method = RequestMethod.POST, operation = @Operation(operationId = "create", requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = Post.class))), responses = @ApiResponse(responseCode = "201"))), @RouterOperation(path = "/posts/{id}", method = RequestMethod.GET, operation = @Operation(operationId = "get", parameters = @Parameter(name = "id", in = ParameterIn.PATH), responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Post.class))))), @RouterOperation(path = "/posts/{id}", method = RequestMethod.PUT, operation = @Operation(operationId = "update", parameters = @Parameter(name = "id", in = ParameterIn.PATH), responses = @ApiResponse(responseCode = "202", content = @Content(schema = @Schema(implementation = Post.class))))) }) @Bean public RouterFunction<ServerResponse> routes(PostHandler postController) { return route(GET("/posts").and(queryParam("key", "value")), postController::all) .andRoute(POST("/posts"), postController::create) .andRoute(GET("/posts/{id}"), postController::get) .andRoute(PUT("/posts/{id}"), postController::update); }
Example #11
Source File: PositionRouter.java From springdoc-openapi with Apache License 2.0 | 6 votes |
@Bean @RouterOperations({ @RouterOperation(path = "/getAllPositions", operation = @Operation(description = "Get all positions", operationId = "findAll",tags = "positions", responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Position.class)))))), @RouterOperation(path = "/getPosition/{id}", operation = @Operation(description = "Find all", operationId = "findById", tags = "positions",parameters = @Parameter(name = "id", in = ParameterIn.PATH), responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))), @RouterOperation(path = "/createPosition", operation = @Operation(description = "Save position", operationId = "save", tags = "positions",requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = Position.class))), responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))), @RouterOperation(path = "/deletePosition/{id}", operation = @Operation(description = "Delete By Id", operationId = "deleteBy",tags = "positions", parameters = @Parameter(name = "id", in = ParameterIn.PATH), responses = @ApiResponse(responseCode = "200", content = @Content)))}) public RouterFunction<ServerResponse> positionRoute(PositionHandler handler) { return RouterFunctions .route(GET("/getAllPositions").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) .andRoute(GET("/getPosition/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) .andRoute(POST("/createPosition").and(accept(MediaType.APPLICATION_JSON)), handler::save) .andRoute(DELETE("/deletePosition/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete); }
Example #12
Source File: MCRRestObjects.java From mycore with GNU General Public License v3.0 | 6 votes |
@GET @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON + ";charset=UTF-8" }) @MCRCacheControl(maxAge = @MCRCacheControl.Age(time = 1, unit = TimeUnit.HOURS), sMaxAge = @MCRCacheControl.Age(time = 1, unit = TimeUnit.HOURS)) @Operation( summary = "Lists all objects in this repository", responses = @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = MCRObjectIDDate.class)))), tags = MCRRestUtils.TAG_MYCORE_OBJECT) @XmlElementWrapper(name = "mycoreobjects") @JacksonFeatures(serializationDisable = { SerializationFeature.WRITE_DATES_AS_TIMESTAMPS }) public Response listObjects() throws IOException { Date lastModified = new Date(MCRXMLMetadataManager.instance().getLastModified()); Optional<Response> cachedResponse = MCRRestUtils.getCachedResponse(request, lastModified); if (cachedResponse.isPresent()) { return cachedResponse.get(); } List<MCRRestObjectIDDate> idDates = MCRXMLMetadataManager.instance().listObjectDates().stream() .filter(oid -> !oid.getId().contains("_derivate_")) .map(x -> new MCRRestObjectIDDate(x)) .collect(Collectors.toList()); return Response.ok(new GenericEntity<List<MCRRestObjectIDDate>>(idDates) { }) .lastModified(lastModified) .build(); }
Example #13
Source File: BookStoreOpenApi.java From cxf with Apache License 2.0 | 6 votes |
@Produces({ MediaType.APPLICATION_JSON }) @GET @Operation( description = "Get books", responses = @ApiResponse( responseCode = "200", content = @Content( mediaType = MediaType.APPLICATION_JSON, array = @ArraySchema(schema = @Schema(implementation = Book.class)) ) ) ) public Response getBooks( @Parameter(description = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1") int page) { return Response.ok( Arrays.asList( new Book("Book 1", 1), new Book("Book 2", 2) ) ).build(); }
Example #14
Source File: ProductReleaseEndpoint.java From pnc with Apache License 2.0 | 6 votes |
/** * {@value GET_SUPPORT_LEVELS} * * @return */ @Operation( summary = GET_SUPPORT_LEVELS, responses = { @ApiResponse( responseCode = SUCCESS_CODE, description = SUCCESS_DESCRIPTION, content = @Content( array = @ArraySchema(schema = @Schema(implementation = SupportLevel.class)))), @ApiResponse( responseCode = SERVER_ERROR_CODE, description = SERVER_ERROR_DESCRIPTION, content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @GET @Path("/support-levels") Set<SupportLevel> getSupportLevels();
Example #15
Source File: ExtensionHandler.java From syndesis with Apache License 2.0 | 5 votes |
@POST @Path("/{id}/validation") @Produces(MediaType.APPLICATION_JSON) @ApiResponse(responseCode = "200", description = "All blocking validations pass", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Violation.class)))) @ApiResponse(responseCode = "400", description = "Found violations in validation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Violation.class)))) public Set<Violation> validate(@NotNull @PathParam("id") final String extensionId) { Extension extension = getDataManager().fetch(Extension.class, extensionId); return doValidate(extension); }
Example #16
Source File: Swagger2Module.java From jsonschema-generator with Apache License 2.0 | 5 votes |
/** * Determine the given field/method's {@link ArraySchema} annotation is present and contains a specific {@code minItems}. * * @param member potentially annotated field/method * @return the {@code @ArraySchema(minItems)} value, otherwise {@code null} */ protected Integer resolveArrayMinItems(MemberScope<?, ?> member) { if (member.isFakeContainerItemScope()) { return null; } return this.getArraySchemaAnnotation(member) .map(ArraySchema::minItems) .filter(minItems -> minItems != Integer.MAX_VALUE) .orElse(null); }
Example #17
Source File: Sample2.java From cxf with Apache License 2.0 | 5 votes |
@Produces({ MediaType.APPLICATION_JSON }) @GET @Operation( summary = "Get all items", description = "Get operation with Response and @Default value", responses = { @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Item.class))), responseCode = "200" ) } ) public Response getItems(@Parameter(required = true) @QueryParam("page") @DefaultValue("1") int page) { return Response.ok(items.values()).build(); }
Example #18
Source File: Sample.java From cxf with Apache License 2.0 | 5 votes |
@Produces({ MediaType.APPLICATION_JSON }) @GET @Operation( summary = "Get all items", description = "Get operation with Response and @Default value", responses = { @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Item.class))), responseCode = "200" ) } ) public Response getItems(@Parameter(required = true) @QueryParam("page") @DefaultValue("1") int page) { return Response.ok(items.values()).build(); }
Example #19
Source File: Sample.java From cxf with Apache License 2.0 | 5 votes |
@Produces({ MediaType.APPLICATION_JSON }) @GET @Operation( summary = "Get all items", description = "Get operation with Response and @Default value", responses = { @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Item.class))), responseCode = "200" ) } ) public Response getItems(@Parameter(required = true) @QueryParam("page") @DefaultValue("1") int page) { return Response.ok(items.values()).build(); }
Example #20
Source File: PetsService.java From lagom-openapi with Apache License 2.0 | 5 votes |
@Operation( operationId = "find", description = "Returns all pets from the system that the user has access to", parameters = { @Parameter( name = "tags", description = "tags to filter by", in = QUERY, style = ParameterStyle.FORM, array = @ArraySchema(schema = @Schema(implementation = String.class)) ), @Parameter( name = "limit", description = "maximum number of results to return", in = QUERY, schema = @Schema(implementation = Integer.class) ) }, responses = { @ApiResponse( responseCode = "200", description = "pet response", content = @Content( mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = Pet.class)) ) ), @ApiResponse( description = "unexpected error", content = @Content( mediaType = "application/json", schema = @Schema(implementation = LagomError.class) ) ) } ) ServiceCall<NotUsed, List<Pet>> find(List<String> tags, Optional<Integer> limit);
Example #21
Source File: ArrayParameterService.java From lagom-openapi with Apache License 2.0 | 5 votes |
@Operation( operationId = "test", description = "array schema param test", parameters = { @Parameter(in = ParameterIn.QUERY, name = "params", required = true, explode = Explode.TRUE, array = @ArraySchema(maxItems = 10, minItems = 1, schema = @Schema(implementation = String.class), uniqueItems = true ) ), } ) ServiceCall<NotUsed, NotUsed> test(List<String> params);
Example #22
Source File: Sample.java From cxf with Apache License 2.0 | 5 votes |
@Produces({ MediaType.APPLICATION_JSON }) @GET @Operation( summary = "Get all items", description = "Get operation with Response and @Default value", responses = { @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Item.class))), responseCode = "200" ) } ) public Response getItems(@Parameter(required = true) @QueryParam("page") @DefaultValue("1") int page) { return Response.ok(items.values()).build(); }
Example #23
Source File: Validating.java From syndesis with Apache License 2.0 | 5 votes |
@POST @Path(value = "/validation") @Consumes("application/json") @Produces(MediaType.APPLICATION_JSON) @ApiResponse(responseCode = "204", description = "All validations pass") @ApiResponse(responseCode = "400", description = "Found violations in validation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Violation.class)))) default Response validate(@NotNull final T obj) { final Set<ConstraintViolation<T>> constraintViolations = getValidator().validate(obj, AllValidations.class); if (constraintViolations.isEmpty()) { return Response.noContent().build(); } throw new ConstraintViolationException(constraintViolations); }
Example #24
Source File: MCRRestDerivates.java From mycore with GNU General Public License v3.0 | 5 votes |
@GET @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON + ";charset=UTF-8" }) @MCRCacheControl(maxAge = @MCRCacheControl.Age(time = 1, unit = TimeUnit.DAYS), sMaxAge = @MCRCacheControl.Age(time = 1, unit = TimeUnit.DAYS)) @Operation( summary = "Lists all derivates in the given object", responses = { @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = MCRMetaLinkID.class)))), @ApiResponse(responseCode = "" + MCRObjectIDParamConverterProvider.CODE_INVALID, description = MCRObjectIDParamConverterProvider.MSG_INVALID), }, tags = MCRRestUtils.TAG_MYCORE_DERIVATE) @XmlElementWrapper(name = "derobjects") public Response listDerivates() throws IOException { long modified = MCRXMLMetadataManager.instance().getLastModified(mcrId); if (modified < 0) { throw MCRErrorResponse.fromStatus(Response.Status.NOT_FOUND.getStatusCode()) .withErrorCode(MCRErrorCodeConstants.MCROBJECT_NOT_FOUND) .withMessage("MCRObject " + mcrId + " not found") .toException(); } Date lastModified = new Date(modified); Optional<Response> cachedResponse = MCRRestUtils.getCachedResponse(request, lastModified); if (cachedResponse.isPresent()) { return cachedResponse.get(); } MCRObject obj = MCRMetadataManager.retrieveMCRObject(mcrId); List<MCRMetaEnrichedLinkID> derivates = obj.getStructure().getDerivates(); return Response.ok() .entity(new GenericEntity<List<MCRMetaEnrichedLinkID>>(derivates){}) .lastModified(lastModified) .build(); }
Example #25
Source File: ExtensionHandler.java From syndesis with Apache License 2.0 | 5 votes |
@POST @Path(value = "/validation") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @ApiResponse(responseCode = "200", description = "All blocking validations pass", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Violation.class)))) @ApiResponse(responseCode = "400", description = "Found violations in validation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Violation.class)))) public Set<Violation> validate(@NotNull final Extension extension) { return doValidate(extension); }
Example #26
Source File: ExtensionHandler.java From syndesis with Apache License 2.0 | 5 votes |
@POST @Path(value = "/{id}/install") @ApiResponse(responseCode = "200", description = "Installed", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Violation.class)))) @ApiResponse(responseCode = "400", description = "Found violations in validation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Violation.class)))) public void install(@NotNull @PathParam("id") final String id) { Extension extension = getDataManager().fetch(Extension.class, id); doValidate(extension); extensionActivator.activateExtension(extension); }
Example #27
Source File: Sample.java From cxf with Apache License 2.0 | 5 votes |
@Produces({ MediaType.APPLICATION_JSON }) @GET @Operation( summary = "Get all items", description = "Get operation with Response and @Default value", responses = { @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Item.class))), responseCode = "200" ) } ) public Response getItems(@Parameter(required = true) @QueryParam("page") @DefaultValue("1") int page) { return Response.ok(items.values()).build(); }
Example #28
Source File: BuildConfigurationEndpoint.java From pnc with Apache License 2.0 | 5 votes |
/** * {@value GET_SUPPORTED_PARAMS_DESC} {@value GET_SUPPORTED_PARAMS_DESC2} * * @return */ @Operation( summary = GET_SUPPORTED_PARAMS_DESC, description = GET_SUPPORTED_PARAMS_DESC2, responses = { @ApiResponse( responseCode = SUCCESS_CODE, description = SUCCESS_DESCRIPTION, content = @Content( array = @ArraySchema( schema = @Schema(implementation = org.jboss.pnc.dto.response.Parameter.class)))) }) @GET @Path("/supported-parameters") Set<org.jboss.pnc.dto.response.Parameter> getSupportedParameters();
Example #29
Source File: FooBarController.java From tutorials with MIT License | 5 votes |
@Operation(summary = "Get all foos") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "found foos", content = { @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = Foo.class)))}), @ApiResponse(responseCode = "404", description = "No Foos found", content = @Content) }) @GetMapping public ResponseEntity<List<Foo>> getAllFoos() { List<Foo> fooList = (List<Foo>) repository.findAll(); if (fooList.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } return new ResponseEntity<>(fooList, HttpStatus.OK); }
Example #30
Source File: StepActionHandler.java From syndesis with Apache License 2.0 | 5 votes |
@POST @Path("/descriptor") @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Retrieves enriched step definitions, that is a list of steps where each step has adapted input/output data shapes " + "defined with respect to the given shape variants") @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Step.class))), description = "List of enriched steps") public Response enrichStepMetadata(List<Step> steps) { List<Step> enriched = new ArrayList<>(steps.size()); for (int i = 0; i < steps.size(); i++) { Step step = steps.get(i); final Optional<StepMetadataHandler> metadataHandler = findStepMetadataHandler(step.getStepKind()); if (metadataHandler.isPresent()) { StepMetadataHandler handler = metadataHandler.get(); List<Step> previousSteps; if (i == 0) { previousSteps = Collections.singletonList(step); } else { previousSteps = enriched.subList(0, i); } final DynamicActionMetadata metadata = handler.createMetadata(step, previousSteps, steps.subList(i + 1, steps.size())); final DynamicActionMetadata enrichedMetadata = handler.handle(metadata); if (enrichedMetadata.equals(DynamicActionMetadata.NOTHING)) { enriched.add(step); } else { enriched.add(applyMetadata(step, enrichedMetadata)); } } else { enriched.add(step); } } return Response.status(Status.OK).entity(enriched).build(); }