本文整理匯總了Java中io.swagger.annotations.ApiResponses類的典型用法代碼示例。如果您正苦於以下問題:Java ApiResponses類的具體用法?Java ApiResponses怎麽用?Java ApiResponses使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ApiResponses類屬於io.swagger.annotations包,在下文中一共展示了ApiResponses類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: userAddPost
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@ApiOperation(value = "用戶新增", notes = "用戶新增", response = ResultDTO.class, tags = { "ZhihuUser", })
@ApiResponses(value = { @ApiResponse(code = 200, message = "返回應用服務器的請求列表", response = ResultDTO.class),
@ApiResponse(code = 200, message = "返回錯誤信息", response = ResultDTO.class) })
@RequestMapping(value = "/user/add", produces = { "application/json" }, method = RequestMethod.POST)
public ResponseEntity<ResultDTO> userAddPost(
@NotNull @ApiParam(value = "用戶名", required = false, defaultValue = "夕陽晚晴") @RequestParam(value = "username", required = false) String username,
@NotNull @ApiParam(value = "user token", required = false, defaultValue = "xi-yang-wan-qing-30") @RequestParam(value = "userToken", required = false) String userToken,
@NotNull @ApiParam(value = "位置", required = false) @RequestParam(value = "location", required = false) String location,
@NotNull @ApiParam(value = "行業", required = false, defaultValue = "互聯網") @RequestParam(value = "business", required = false) String business,
@NotNull @ApiParam(value = "性別", required = false, defaultValue = "male") @RequestParam(value = "sex", required = false) String sex,
@NotNull @ApiParam(value = "企業", required = false) @RequestParam(value = "employment", required = false) String employment,
@NotNull @ApiParam(value = "教育", required = false) @RequestParam(value = "education", required = false) String education,
@NotNull @ApiParam(value = "用戶首頁url", required = false, defaultValue = "https://www.zhihu.com/people/xi-yang-wan-qing-30/activities") @RequestParam(value = "url", required = false) String url,
@NotNull @ApiParam(value = "答案讚同數", required = false, defaultValue = "0") @RequestParam(value = "agrees", required = false) Integer agrees,
@NotNull @ApiParam(value = "感謝數", required = false, defaultValue = "0") @RequestParam(value = "thanks", required = false) Integer thanks,
@NotNull @ApiParam(value = "提問數", required = false, defaultValue = "0") @RequestParam(value = "asks", required = false) Integer asks,
@NotNull @ApiParam(value = "回答數", required = false, defaultValue = "0") @RequestParam(value = "answers", required = false) Integer answers,
@NotNull @ApiParam(value = "文章數", required = false, defaultValue = "0") @RequestParam(value = "posts", required = false) Integer posts,
@NotNull @ApiParam(value = "關注人數", required = false, defaultValue = "1") @RequestParam(value = "followees", required = false) Integer followees,
@NotNull @ApiParam(value = "粉絲數量", required = false, defaultValue = "0") @RequestParam(value = "followers", required = false) Integer followers,
@NotNull @ApiParam(value = "用戶唯一標識", required = false, defaultValue = "88fb5d79df5a332cf16c8f8ad659dcf4") @RequestParam(value = "hashId", required = false) String hashId);
示例2: getAdaptorConfiguration
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@ApiOperation(value = "getAdaptorConfiguration", nickname = "getAdaptorConfiguration")
@RequestMapping(value = "/CISCore/getAdaptorConfiguration", method = RequestMethod.GET)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = AdaptorConfigurationImpl.class),
@ApiResponse(code = 400, message = "Bad Request", response = AdaptorConfigurationImpl.class),
@ApiResponse(code = 500, message = "Failure", response = AdaptorConfigurationImpl.class)})
public ResponseEntity<AdaptorConfigurationImpl> getAdaptorConfiguration() {
log.info("--> getAdaptorConfiguration");
AdaptorConfigurationImpl config = (AdaptorConfigurationImpl)cisCore.getAdaptorConfiguration();
HttpHeaders responseHeaders = new HttpHeaders();
log.info("getAdaptorConfiguration -->");
return new ResponseEntity<AdaptorConfigurationImpl>(config, responseHeaders, HttpStatus.OK);
}
示例3: list
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@GET
@Produces({"application/hal+json", "application/hal+json;concept=virtualaccount;v=1"})
@ApiOperation(value = "lists accounts", response = VirtualAccountsRepresentation.class,
authorizations = {
@Authorization(value = "oauth2", scopes = {}),
@Authorization(value = "oauth2-cc", scopes = {}),
@Authorization(value = "oauth2-ac", scopes = {}),
@Authorization(value = "oauth2-rop", scopes = {}),
@Authorization(value = "Bearer")
},
extensions = {@Extension(name = "roles", properties = {
@ExtensionProperty(name = "advisor", value = "advisors are allowed getting every virtualaccount"),
@ExtensionProperty(name = "customer", value = "customer only allowed getting own locations")}
)},
produces = "application/hal+json, application/hal+json;concept=locations;v=1",
notes = "List all locations in a default projection, which is VirtualAccount version 1" +
"Supported projections and versions are: " +
"VirtualAccounts in version 1 " +
"The Accept header for the default version is application/hal+json;concept=virtualaccount;v=1.0.0.... " +
"The format for the default version is {....}", nickname = "listVirtualAccounts")
@ApiResponses(value = {
@ApiResponse(code = 415, message = "Content type not supported.")
})
public Response list(@Context UriInfo uriInfo, @Context Request request, @HeaderParam("Accept") String accept) {
return accountsProducer.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request);
}
示例4: getApplicantDetail
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@GET
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Get a detail applicant", response = ApplicantModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a applicant", response = ApplicantModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response getApplicantDetail(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") long id);
示例5: endpoint
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@ApiOperation(
value = "Updates an Manager Connector. If we are unable to connect to the endpoint(IP) using the credentials provided, this call will fail.",
notes = "Creates an Manager Connector and sync's it immediately. "
+ "If we are unable to connect to the manager using the credentials provided, this call will fail."
+ "To skip validation of IP and credentials 'skipRemoteValidation' flag can be used.",
response = BaseJobResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 400,
message = "In case of any error validating the information",
response = ErrorCodeDto.class) })
@Path("/{applianceManagerConnectorId}")
@PUT
public Response updateApplianceManagerConnector(@Context HttpHeaders headers,
@ApiParam(value = "Id of the Appliance Manager Connector",
required = true) @PathParam("applianceManagerConnectorId") Long amcId,
@ApiParam(required = true) ApplianceManagerConnectorRequest amcRequest) {
logger.info("Updating Appliance Manager Connector " + amcId);
this.userContext.setUser(OscAuthFilter.getUsername(headers));
this.apiUtil.setIdOrThrow(amcRequest, amcId, "Appliance Manager Connector");
Response responseForBaseRequest = this.apiUtil.getResponseForBaseRequest(this.updateService,
new DryRunRequest<>(amcRequest, amcRequest.isSkipRemoteValidation()));
return responseForBaseRequest;
}
示例6: getParticipantFromCGOR
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@ApiOperation(value = "getParticipantFromCGOR", nickname = "getParticipantFromCGOR")
@RequestMapping(value = "/CISConnector/getParticipantFromCGOR/{cgorName}", method = RequestMethod.GET)
@ApiImplicitParams({
@ApiImplicitParam(name = "cgorName", value = "the CGOR name", required = true, dataType = "String", paramType = "path"),
@ApiImplicitParam(name = "organisation", value = "the Organisation name", required = true, dataType = "String", paramType = "query")
})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = Participant.class),
@ApiResponse(code = 400, message = "Bad Request", response = Participant.class),
@ApiResponse(code = 500, message = "Failure", response = Participant.class)})
public ResponseEntity<Participant> getParticipantFromCGOR(@PathVariable String cgorName, @QueryParam("organisation") String organisation) {
log.info("--> getParticipantFromCGOR: " + cgorName);
Participant participant;
try {
participant = connector.getParticipantFromCGOR(cgorName, organisation);
} catch (CISCommunicationException e) {
log.error("Error executing the request: Communication Error" , e);
participant = null;
}
HttpHeaders responseHeaders = new HttpHeaders();
log.info("getParticipantFromCGOR -->");
return new ResponseEntity<Participant>(participant, responseHeaders, HttpStatus.OK);
}
示例7: validate
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
/**
* Validate logins yml.
* @param loginsYml logins yml
* @return true if valid
*/
@PostMapping(value = "/logins/validate", consumes = {TEXT_PLAIN_VALUE})
@ApiOperation(value = "Validate uaa login properties format", response = UaaValidationVM.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Uaa validation result", response = UaaValidationVM.class),
@ApiResponse(code = 500, message = "Internal server error")})
@SneakyThrows
@Timed
public UaaValidationVM validate(@RequestBody String loginsYml) {
try {
mapper.readValue(loginsYml, TenantLogins.class);
return UaaValidationVM.builder().isValid(true).build();
} catch (JsonParseException | JsonMappingException e) {
return UaaValidationVM.builder().isValid(false).errorMessage(e.getLocalizedMessage()).build();
}
}
示例8: createFlow
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Creates a flow",
notes = "The flow id is created by the server and populated in the returned entity.",
response = VersionedFlow.class
)
@ApiResponses({
@ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
@ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
@ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
@ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
@ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response createFlow(
@PathParam("bucketId")
@ApiParam("The bucket identifier")
final String bucketId, final VersionedFlow flow) {
authorizeBucketAccess(RequestAction.WRITE, bucketId);
verifyPathParamsMatchBody(bucketId, flow);
final VersionedFlow createdFlow = registryService.createFlow(bucketId, flow);
permissionsService.populateItemPermissions(createdFlow);
linkService.populateFlowLinks(createdFlow);
return Response.status(Response.Status.OK).entity(createdFlow).build();
}
示例9: authenticate
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Authenticate a user", notes = "Verify a user credentials")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "user authenticated"),
@ApiResponse(code = 401, message = "Wrong user or password")})
public Response authenticate(Credentials credentials) {
if (UsersDao.authenticate(credentials)) {
byte[] bearer = UsersDao.getBearer(credentials);
StringBuilder auth = new StringBuilder().append("Bearer ").append(PasswordStorage.toBase64(bearer));
return Response.ok()
.cookie(new NewCookie("Authorization", auth.toString(), null, null,
DEFAULT_VERSION, null, DEFAULT_MAX_AGE, null, true, true))
.entity(new ResponseMessage(true, "user authenticated")).build();
} else {
return Response.status(UNAUTHORIZED)
.entity(new ResponseMessage(false, "Username or password is incorrect")).build();
}
}
示例10: getById
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@GET
@Produces({APPLICATION_JSON, APPLICATION_XML})
@Path("/{id : \\d+}")
@ApiOperation(value = "Get user by id", notes = "Returns user identified by is internal id")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 404, message = "User not found"),
@ApiResponse(code = 500, message = "Something wrong in Server")})
public Response getById(@PathParam("id") long id) {
Optional<User> userOptional = UsersDao.getById(id);
if (userOptional.isPresent()) {
return Response.ok().entity(userOptional.get()).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
示例11: createSecurityGroup
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@ApiOperation(value = "Creates a Security Group",
notes = "Creates a Security Group owned by Virtualization Connector provided and kicks off a " + "sync job",
response = BaseJobResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/{vcId}/securityGroups")
@POST
public Response createSecurityGroup(@Context HttpHeaders headers,
@ApiParam(value = "The Virtualization Connector Id") @PathParam("vcId") Long vcId,
@ApiParam(required = true) SecurityGroupDto sgDto) {
logger.info("Creating Security Group ...");
this.userContext.setUser(OscAuthFilter.getUsername(headers));
this.apiUtil.setIdAndParentIdOrThrow(sgDto, null, vcId, "Security Group");
AddOrUpdateSecurityGroupRequest request = new AddOrUpdateSecurityGroupRequest();
request.setDto(sgDto);
return this.apiUtil.getResponseForBaseRequest(this.addSecurityGroupService, request);
}
示例12: getSpeaker
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@ApiOperation(
value = "Find speaker by ID",
notes = "For valid response try integer IDs with value 1 ... 999. Other values will generated exceptions",
response = SpeakerResource.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful retrieve the speaker.", response = SpeakerResource.class),
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "Speaker not found"),
@ApiResponse(code = 500, message = "Internal server error.")})
@GetMapping(value = "/{id}")
public ResponseEntity<SpeakerResource> getSpeaker(
@ApiParam(value = "ID of speaker that needs to be fetched",
allowableValues = "range[1,999]",
required = true)
@PathVariable long id) {
return speakerRepository.findOne(id)
.map(speaker -> ResponseEntity.ok(new SpeakerResource(speaker)))
.orElse(new ResponseEntity(HttpStatus.NOT_FOUND));
}
示例13: getConfig
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@GET
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "Get list of all available configuration files")
@ApiResponses(value = {
@ApiResponse(code = 207, message = "Multiple responses available"),
@ApiResponse(code = 400, message = "Request contains invalid parameters")})
public Response getConfig(@QueryParam("scope") String scope,
@QueryParam("nodeId") List<String> nodeId)
{
ApiRequester apiRequester = requesterBuilder(ControllerConfigAPI.class)
.httpMethod(GET)
.accept(MediaType.TEXT_PLAIN)
.build();
return forwardRequest(scope, apiRequester, nodeId);
}
示例14: countCustomer
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@GET
@Path("/countCustomers")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get the Customer Resource.",produces=MediaType.APPLICATION_JSON, response = Long.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "CustomerCount Resource is found"),
@ApiResponse(code = 404, message = "CustomerCount Resource cannot be found")
})
public long countCustomer() {
try {
return customerService.count();
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
示例15: getOrganisationList
import io.swagger.annotations.ApiResponses; //導入依賴的package包/類
@ApiOperation(value = "getOrganisationList", nickname = "getOrganisationList")
@RequestMapping(value = "/CISCore/getOrganisationList", method = RequestMethod.GET)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = ResponseEntity.class),
@ApiResponse(code = 400, message = "Bad Request", response = ResponseEntity.class),
@ApiResponse(code = 500, message = "Failure", response = ResponseEntity.class)})
public ResponseEntity<List<Organisation>> getOrganisationList() throws CISCommunicationException {
log.info("--> getOrganisationList");
List<Organisation> organisationList = new ArrayList<Organisation>();
try {
organisationList = cisCore.getOrganisationList();
} catch (CISCommunicationException e) {
log.error("Error executing the request: Communication Error" , e);
organisationList = null;
}
HttpHeaders responseHeaders = new HttpHeaders();
log.info("getOrganisationList -->");
return new ResponseEntity<List<Organisation>>(organisationList, responseHeaders, HttpStatus.OK);
}