use of io.swagger.annotations.ApiResponse in project java-chassis by ServiceComb.
the class ApiResponseClassProcessor method process.
@Override
public void process(Object annotation, SwaggerGenerator swaggerGenerator) {
// swagger号称不允许独立使用这个标注,不过支持独立使用,也没什么后果
ApiResponse apiResponse = (ApiResponse) annotation;
AnnotationUtils.addResponse(swaggerGenerator.getSwagger(), apiResponse);
}
use of io.swagger.annotations.ApiResponse in project java-chassis by ServiceComb.
the class CodeFirstSpringmvc method cseResponse.
@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@RequestMapping(path = "/cseResponse", method = RequestMethod.GET)
public Response cseResponse() {
Response response = Response.createSuccess(Status.ACCEPTED, new User());
response.getHeaders().addHeader("h1", "h1v").addHeader("h2", "h2v");
return response;
}
use of io.swagger.annotations.ApiResponse in project graylog2-server by Graylog2.
the class MessageResource method analyze.
@GET
@Path("/{index}/analyze")
@Timed
@ApiOperation(value = "Analyze a message string", notes = "Returns what tokens/terms a message string (message or full_message) is split to.")
@RequiresPermissions(RestPermissions.MESSAGES_ANALYZE)
@ApiResponses(value = { @ApiResponse(code = 404, message = "Specified index does not exist.") })
public MessageTokens analyze(@ApiParam(name = "index", value = "The index the message containing the string is stored in.", required = true) @PathParam("index") String index, @ApiParam(name = "analyzer", value = "The analyzer to use.") @QueryParam("analyzer") @Nullable String analyzer, @ApiParam(name = "string", value = "The string to analyze.", required = true) @QueryParam("string") @NotEmpty String string) {
final String indexAnalyzer = indexSetRegistry.getForIndex(index).map(indexSet -> indexSet.getConfig().indexAnalyzer()).orElse("standard");
final String messageAnalyzer = analyzer == null ? indexAnalyzer : analyzer;
try {
return MessageTokens.create(messages.analyze(string, index, messageAnalyzer));
} catch (IndexNotFoundException e) {
final String message = "Index " + index + " does not exist.";
LOG.error(message, e);
throw new NotFoundException(message);
}
}
use of io.swagger.annotations.ApiResponse in project graylog2-server by Graylog2.
the class Generator method determineResponses.
private List<Map<String, Object>> determineResponses(Method method) {
final List<Map<String, Object>> result = Lists.newArrayList();
final ApiResponses annotation = method.getAnnotation(ApiResponses.class);
if (null != annotation) {
for (ApiResponse response : annotation.value()) {
final Map<String, Object> responseDescription = ImmutableMap.<String, Object>of("code", response.code(), "message", response.message());
result.add(responseDescription);
}
}
return result;
}
use of io.swagger.annotations.ApiResponse in project graylog2-server by Graylog2.
the class IndexSetsResource method get.
@GET
@Path("{id}")
@Timed
@ApiOperation(value = "Get index set")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Unauthorized"), @ApiResponse(code = 404, message = "Index set not found") })
public IndexSetSummary get(@ApiParam(name = "id", required = true) @PathParam("id") String id) {
checkPermission(RestPermissions.INDEXSETS_READ, id);
final IndexSetConfig defaultIndexSet = indexSetService.getDefault();
return indexSetService.get(id).map(config -> IndexSetSummary.fromIndexSetConfig(config, config.equals(defaultIndexSet))).orElseThrow(() -> new NotFoundException("Couldn't load index set with ID <" + id + ">"));
}
Aggregations