List of usage examples for org.springframework.web.bind.annotation RequestMethod HEAD
RequestMethod HEAD
To view the source code for org.springframework.web.bind.annotation RequestMethod HEAD.
Click Source Link
From source file:alfio.controller.EventController.java
@RequestMapping(value = "/event/{eventName}", method = { RequestMethod.GET, RequestMethod.HEAD }) public String showEvent(@PathVariable("eventName") String eventName, Model model, HttpServletRequest request, Locale locale) {/*from w ww .j a v a2s. com*/ return eventRepository.findOptionalByShortName(eventName) .filter(e -> e.getStatus() != Event.Status.DISABLED).map(event -> { Optional<String> maybeSpecialCode = SessionUtil.retrieveSpecialPriceCode(request); Optional<SpecialPrice> specialCode = maybeSpecialCode .flatMap((trimmedCode) -> specialPriceRepository.getByCode(trimmedCode)); Optional<PromoCodeDiscount> promoCodeDiscount = SessionUtil .retrievePromotionCodeDiscount(request).flatMap((code) -> promoCodeRepository .findPromoCodeInEventOrOrganization(event.getId(), code)); final ZonedDateTime now = ZonedDateTime.now(event.getZoneId()); //hide access restricted ticket categories List<TicketCategory> ticketCategories = ticketCategoryRepository .findAllTicketCategories(event.getId()); Map<Integer, String> categoriesDescription = ticketCategoryDescriptionRepository .descriptionsByTicketCategory(ticketCategories.stream().map(TicketCategory::getId) .collect(Collectors.toList()), locale.getLanguage()); List<SaleableTicketCategory> saleableTicketCategories = ticketCategories.stream() .filter((c) -> !c.isAccessRestricted() || (specialCode .filter(sc -> sc.getTicketCategoryId() == c.getId()).isPresent())) .map((m) -> new SaleableTicketCategory(m, categoriesDescription.getOrDefault(m.getId(), ""), now, event, ticketReservationManager.countAvailableTickets(event, m), configurationManager.getIntConfigValue( Configuration.from(event.getOrganizationId(), event.getId(), m.getId(), ConfigurationKeys.MAX_AMOUNT_OF_TICKETS_BY_RESERVATION), 5), promoCodeDiscount.filter(promoCode -> shouldApplyDiscount(promoCode, m)) .orElse(null))) .collect(Collectors.toList()); // final int orgId = event.getOrganizationId(); final int eventId = event.getId(); Map<ConfigurationKeys, Optional<String>> geoInfoConfiguration = configurationManager .getStringConfigValueFrom( Configuration.from(orgId, eventId, ConfigurationKeys.MAPS_PROVIDER), Configuration.from(orgId, eventId, ConfigurationKeys.MAPS_CLIENT_API_KEY), Configuration.from(orgId, eventId, ConfigurationKeys.MAPS_HERE_APP_ID), Configuration.from(orgId, eventId, ConfigurationKeys.MAPS_HERE_APP_CODE)); LocationDescriptor ld = LocationDescriptor.fromGeoData(event.getLatLong(), TimeZone.getTimeZone(event.getTimeZone()), geoInfoConfiguration); final boolean hasAccessPromotions = ticketCategoryRepository .countAccessRestrictedRepositoryByEventId(event.getId()) > 0 || promoCodeRepository.countByEventAndOrganizationId(event.getId(), event.getOrganizationId()) > 0; String eventDescription = eventDescriptionRepository .findDescriptionByEventIdTypeAndLocale(event.getId(), EventDescription.EventDescriptionType.DESCRIPTION, locale.getLanguage()) .orElse(""); final EventDescriptor eventDescriptor = new EventDescriptor(event, eventDescription); List<SaleableTicketCategory> expiredCategories = saleableTicketCategories.stream() .filter(SaleableTicketCategory::getExpired).collect(Collectors.toList()); List<SaleableTicketCategory> validCategories = saleableTicketCategories.stream() .filter(tc -> !tc.getExpired()).collect(Collectors.toList()); List<SaleableAdditionalService> additionalServices = additionalServiceRepository .loadAllForEvent(event.getId()).stream().map((as) -> getSaleableAdditionalService(event, locale, as, promoCodeDiscount.orElse(null))) .collect(Collectors.toList()); Predicate<SaleableTicketCategory> waitingQueueTargetCategory = tc -> !tc.getExpired() && !tc.isBounded(); boolean validPaymentConfigured = isEventHasValidPaymentConfigurations(event, configurationManager); List<SaleableAdditionalService> notExpiredServices = additionalServices.stream() .filter(SaleableAdditionalService::isNotExpired).collect(Collectors.toList()); List<SaleableAdditionalService> supplements = adjustIndex(0, notExpiredServices.stream() .filter(a -> a.getType() == AdditionalService.AdditionalServiceType.SUPPLEMENT) .collect(Collectors.toList())); List<SaleableAdditionalService> donations = adjustIndex(supplements.size(), notExpiredServices.stream() .filter(a -> a.getType() == AdditionalService.AdditionalServiceType.DONATION) .collect(Collectors.toList())); model.addAttribute("event", eventDescriptor)// .addAttribute("organization", organizationRepository.getById(event.getOrganizationId())) .addAttribute("ticketCategories", validCategories)// .addAttribute("expiredCategories", expiredCategories)// .addAttribute("containsExpiredCategories", !expiredCategories.isEmpty())// .addAttribute("showNoCategoriesWarning", validCategories.isEmpty()) .addAttribute("hasAccessPromotions", hasAccessPromotions) .addAttribute("promoCode", specialCode.map(SpecialPrice::getCode).orElse(null)) .addAttribute("locationDescriptor", ld) .addAttribute("pageTitle", "show-event.header.title") .addAttribute("hasPromoCodeDiscount", promoCodeDiscount.isPresent()) .addAttribute("promoCodeDiscount", promoCodeDiscount.orElse(null)) .addAttribute("displayWaitingQueueForm", EventUtil.displayWaitingQueueForm(event, saleableTicketCategories, configurationManager, eventStatisticsManager.noSeatsAvailable())) .addAttribute("displayCategorySelectionForWaitingQueue", saleableTicketCategories.stream().filter(waitingQueueTargetCategory) .count() > 1) .addAttribute("unboundedCategories", saleableTicketCategories.stream().filter(waitingQueueTargetCategory) .collect(Collectors.toList())) .addAttribute("preSales", EventUtil.isPreSales(event, saleableTicketCategories)) .addAttribute("userLanguage", locale.getLanguage()) .addAttribute("showAdditionalServices", !notExpiredServices.isEmpty()) .addAttribute("showAdditionalServicesDonations", !donations.isEmpty()) .addAttribute("showAdditionalServicesSupplements", !supplements.isEmpty()) .addAttribute("enabledAdditionalServicesDonations", donations) .addAttribute("enabledAdditionalServicesSupplements", supplements) .addAttribute("forwardButtonDisabled", (saleableTicketCategories.stream() .noneMatch(SaleableTicketCategory::getSaleable)) || !validPaymentConfigured) .addAttribute("useFirstAndLastName", event.mustUseFirstAndLastName()) .addAttribute("validPaymentMethodAvailable", validPaymentConfigured) .addAttribute("validityStart", event.getBegin()) .addAttribute("validityEnd", event.getEnd()); model.asMap().putIfAbsent("hasErrors", false);// return "/event/show-event"; }).orElse(REDIRECT + "/"); }
From source file:edu.mayo.cts2.framework.webapp.rest.controller.ConceptDomainController.java
/** * Does concept domain exist./* w ww. ja v a 2s . co m*/ * * @param httpServletResponse the http servlet response * @param conceptDomainName the concept domain name */ @RequestMapping(value = PATH_CONCEPTDOMAIN_BYID, method = RequestMethod.HEAD) @ResponseBody public void doesConceptDomainExist(HttpServletResponse httpServletResponse, @PathVariable(VAR_CONCEPTDOMAINID) String conceptDomainName) { this.doExists(httpServletResponse, this.conceptDomainReadService, UnknownConceptDomain.class, ModelUtils.nameOrUriFromName(conceptDomainName)); }
From source file:edu.mayo.cts2.framework.webapp.rest.controller.MapController.java
/** * Does map exist.// w w w. jav a2s .c om * * @param httpServletResponse the http servlet response * @param mapName the map name */ @RequestMapping(value = PATH_MAP_BYID, method = RequestMethod.HEAD) @ResponseBody public void doesMapExist(HttpServletResponse httpServletResponse, @PathVariable(VAR_MAPID) String mapName) { this.doExists(httpServletResponse, this.mapReadService, UnknownMap.class, ModelUtils.nameOrUriFromName(mapName)); }
From source file:kr.co.exsoft.external.controller.ExternalPublicController.java
@RequestMapping(value = "/restful.jsonhead", method = RequestMethod.HEAD) @ResponseBody//from ww w . j av a 2 s .c o m public List<HashMap<String, Object>> haedTest(Model model, @RequestHeader String key) { logger.info("json return Sample"); List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>(); HashMap<String, Object> data1 = new HashMap<String, Object>(); data1.put("name", "a : " + key); HashMap<String, Object> data2 = new HashMap<String, Object>(); data2.put("userid", "b : " + key); list.add(data1); list.add(data2); return list; }
From source file:edu.mayo.cts2.framework.webapp.rest.controller.CodeSystemController.java
/** * Gets the code systems count./*w w w .ja va 2s.c o m*/ * * @param httpServletResponse the http servlet response * @param query the query * @param resolvedFilter the filter * @return the code systems count */ @RequestMapping(value = PATH_CODESYSTEMS, method = RequestMethod.HEAD) public void getCodeSystemsCount(HttpServletResponse httpServletResponse, RestReadContext restReadContext, RestFilter restFilter) { ResourceQuery resourceQuery = this.getNewResourceQueryBuilder().addRestFilter(restFilter) .addRestReadContext(restReadContext).build(); int count = this.codeSystemQueryService.count(resourceQuery); this.setCount(count, httpServletResponse); }
From source file:edu.mayo.cts2.framework.webapp.rest.controller.ValueSetController.java
/** * Gets the value sets count./*from www.jav a 2 s . c o m*/ * * @param httpServletResponse the http servlet response * @param query the query * @param restrictions the restrictions * @param resolvedFilter the filter * @return the value sets count */ @RequestMapping(value = PATH_VALUESETS, method = RequestMethod.HEAD) @ResponseBody public void getValueSetsCount(HttpServletResponse httpServletResponse, RestReadContext restReadContext, ValueSetQueryServiceRestrictions restrictions, RestFilter restFilter) { ValueSetQueryBuilder builder = this.getNewResourceQueryBuilder(); ValueSetQuery resourceQuery = builder.addRestrictions(restrictions).addRestFilter(restFilter) .addRestReadContext(restReadContext).build(); int count = this.valueSetQueryService.count(resourceQuery); this.setCount(count, httpServletResponse); }
From source file:edu.mayo.cts2.framework.webapp.rest.controller.MapController.java
/** * Gets the maps count.//from www.ja va2 s .co m * * @param httpServletResponse the http servlet response * @param query the query * @param restrictions the restrictions * @param resolvedFilter the filter * @return the maps count */ @RequestMapping(value = PATH_MAPS, method = RequestMethod.HEAD) @ResponseBody public void getMapsCount(HttpServletResponse httpServletResponse, RestReadContext restReadContext, MapQueryServiceRestrictions restrictions, RestFilter restFilter) { MapQueryBuilder builder = this.getNewResourceQueryBuilder(); MapQuery resourceQuery = builder.addRestFilter(restFilter).addRestrictions(restrictions) .addRestReadContext(restReadContext).build(); int count = this.mapQueryService.count(resourceQuery); this.setCount(count, httpServletResponse); }
From source file:edu.mayo.cts2.framework.webapp.rest.controller.ConceptDomainController.java
/** * Gets the concept domains count.//w ww .j ava2 s . com * * @param httpServletResponse the http servlet response * @param query the query * @param resolvedFilter the filter * @return the concept domains count */ @RequestMapping(value = PATH_CONCEPTDOMAINS, method = RequestMethod.HEAD) @ResponseBody public void getConceptDomainsCount(HttpServletResponse httpServletResponse, RestReadContext restReadContext, RestFilter restFilter) { ResourceQueryBuilder builder = this.getNewResourceQueryBuilder(); ResourceQuery resourceQuery = builder.addRestFilter(restFilter).addRestReadContext(restReadContext).build(); int count = this.conceptDomainQueryService.count(resourceQuery); this.setCount(count, httpServletResponse); }
From source file:org.oncoblocks.centromere.web.controller.AbstractApiController.java
/** * {@code HEAD /**}//from w ww .ja v a 2s .c om * Performs a test on the resource endpoints availability. * * @return */ @RequestMapping(value = { "", "/**" }, method = RequestMethod.HEAD) public HttpEntity<?> head(HttpServletRequest request) { return new ResponseEntity<>(HttpStatus.OK); }
From source file:com.angkorteam.framework.swagger.factory.SwaggerFactory.java
@Override public void afterPropertiesSet() throws Exception { Swagger swagger = new Swagger(); io.swagger.models.Info info = new io.swagger.models.Info(); swagger.setInfo(info);/*from w ww . j ava2 s . co m*/ info.setTitle(title); info.setLicense(license); info.setContact(contact); info.setTermsOfService(termsOfService); info.setVersion(version); info.setDescription(description); swagger.setConsumes(consumes); swagger.setProduces(produces); swagger.setSchemes(schemes); swagger.setBasePath(basePath); swagger.setHost(host); swagger.setExternalDocs(externalDocs); ConfigurationBuilder config = new ConfigurationBuilder(); Set<String> acceptablePackages = new HashSet<>(); boolean allowAllPackages = false; if (resourcePackages != null && resourcePackages.length > 0) { for (String resourcePackage : resourcePackages) { if (resourcePackage != null && !"".equals(resourcePackage)) { acceptablePackages.add(resourcePackage); config.addUrls(ClasspathHelper.forPackage(resourcePackage)); } } } config.setScanners(new ResourcesScanner(), new TypeAnnotationsScanner(), new SubTypesScanner()); Reflections reflections = new Reflections(config); Set<Class<?>> controllers = reflections.getTypesAnnotatedWith(Controller.class); Set<Class<?>> output = new HashSet<Class<?>>(); for (Class<?> cls : controllers) { if (allowAllPackages) { output.add(cls); } else { for (String pkg : acceptablePackages) { if (cls.getPackage().getName().startsWith(pkg)) { output.add(cls); } } } } Map<String, Path> paths = new HashMap<>(); swagger.setPaths(paths); Map<String, Model> definitions = new HashMap<>(); swagger.setDefinitions(definitions); Stack<Class<?>> modelStack = new Stack<>(); for (Class<?> controller : controllers) { List<String> clazzPaths = new ArrayList<>(); RequestMapping clazzRequestMapping = controller.getDeclaredAnnotation(RequestMapping.class); Api api = controller.getDeclaredAnnotation(Api.class); if (clazzRequestMapping != null) { clazzPaths = lookPaths(clazzRequestMapping); } if (clazzPaths.isEmpty()) { clazzPaths.add(""); } if (api != null) { if (!"".equals(api.description())) { for (String name : api.tags()) { if (!"".equals(name)) { io.swagger.models.Tag tag = new io.swagger.models.Tag(); tag.setDescription(api.description()); tag.setName(name); swagger.addTag(tag); } } } } else { io.swagger.models.Tag tag = new io.swagger.models.Tag(); tag.setDescription("Unknown"); tag.setName("Unknown"); swagger.addTag(tag); } Method[] methods = null; try { methods = controller.getDeclaredMethods(); } catch (NoClassDefFoundError e) { } if (methods != null && methods.length > 0) { for (Method method : methods) { RequestMapping requestMapping = method.getAnnotation(RequestMapping.class); ApiOperation apiOperation = method.getAnnotation(ApiOperation.class); ApiResponses apiResponses = method.getAnnotation(ApiResponses.class); ApiHeaders apiHeaders = method.getAnnotation(ApiHeaders.class); List<String> methodPaths = new ArrayList<>(); if (requestMapping != null && apiOperation != null && apiResponses != null) { methodPaths = lookPaths(requestMapping); } if (methodPaths.isEmpty()) { methodPaths.add(""); } if (requestMapping != null && apiOperation != null && apiResponses != null) { for (String classPath : clazzPaths) { for (String methodPath : methodPaths) { RequestMethod[] requestMethods = requestMapping.method(); if (requestMethods == null || requestMethods.length == 0) { requestMethods = RequestMethod.values(); } Path path = new Path(); paths.put(classPath + methodPath, path); for (RequestMethod requestMethod : requestMethods) { Operation operation = new Operation(); operation.setDescription(apiOperation.description()); for (String consume : requestMapping.consumes()) { operation.addConsumes(consume); } for (String produce : requestMapping.produces()) { operation.addProduces(produce); } if (api != null) { if (!"".equals(api.description())) { for (String name : api.tags()) { if (!"".equals(name)) { operation.addTag(name); } } } } else { io.swagger.models.Tag tag = new io.swagger.models.Tag(); operation.addTag("Unknown"); } if (requestMethod == RequestMethod.DELETE) { path.delete(operation); } else if (requestMethod == RequestMethod.GET) { path.get(operation); } else if (requestMethod == RequestMethod.HEAD) { path.head(operation); } else if (requestMethod == RequestMethod.OPTIONS) { path.options(operation); } else if (requestMethod == RequestMethod.PATCH) { path.patch(operation); } else if (requestMethod == RequestMethod.POST) { path.post(operation); } else if (requestMethod == RequestMethod.PUT) { path.put(operation); } if (apiHeaders != null && apiHeaders.value() != null && apiHeaders.value().length > 0) { for (ApiHeader header : apiHeaders.value()) { HeaderParameter parameter = new HeaderParameter(); parameter.setName(header.name()); parameter.setType("string"); parameter.setDescription(header.description()); parameter.setRequired(header.required()); operation.addParameter(parameter); } } for (Parameter parameter : method.getParameters()) { PathVariable pathVariable = parameter.getAnnotation(PathVariable.class); RequestParam requestParam = parameter.getAnnotation(RequestParam.class); RequestBody requestBody = parameter.getAnnotation(RequestBody.class); RequestPart requestPart = parameter.getAnnotation(RequestPart.class); ApiParam apiParam = parameter.getAnnotation(ApiParam.class); if (apiParam != null && pathVariable != null && isSimpleScalar(parameter.getType())) { PathParameter pathParameter = new PathParameter(); pathParameter.setRequired(true); pathParameter.setDescription(apiParam.description()); pathParameter.setType(lookupType(parameter.getType())); pathParameter.setFormat(lookupFormat(parameter.getType(), apiParam)); pathParameter.setName(pathVariable.value()); operation.addParameter(pathParameter); continue; } if (requestMethod == RequestMethod.DELETE || requestMethod == RequestMethod.GET || requestMethod == RequestMethod.HEAD || requestMethod == RequestMethod.OPTIONS || requestMethod == RequestMethod.PATCH || requestMethod == RequestMethod.PUT) { if (apiParam != null && requestParam != null && isSimpleArray(parameter.getType())) { QueryParameter param = new QueryParameter(); param.setRequired(requestParam.required()); param.setDescription(apiParam.description()); param.setType("array"); if (!"".equals(requestParam.value())) { param.setName(requestParam.value()); } if (!"".equals(requestParam.name())) { param.setName(requestParam.name()); } param.setItems(lookupProperty(parameter.getType(), requestParam, apiParam)); operation.addParameter(param); continue; } if (apiParam != null && requestParam != null && isSimpleScalar(parameter.getType())) { QueryParameter param = new QueryParameter(); param.setRequired(requestParam.required()); param.setDescription(apiParam.description()); param.setType(lookupType(parameter.getType())); param.setFormat(lookupFormat(parameter.getType(), apiParam)); if (!"".equals(requestParam.value())) { param.setName(requestParam.value()); } if (!"".equals(requestParam.name())) { param.setName(requestParam.name()); } operation.addParameter(param); continue; } if (apiParam != null && requestBody != null && parameter.getType() == MultipartFile.class) { FormParameter param = new FormParameter(); param.setRequired(true); param.setIn("body"); param.setName("body"); param.setType("file"); param.setDescription(apiParam.description()); operation.addConsumes("application/octet-stream"); // BodyParameter param = new BodyParameter(); // param.setRequired(requestBody.required()); // param.setDescription(apiParam.description()); // param.setName("body"); // ModelImpl model = new ModelImpl(); // model.setType("file"); // param.setSchema(model); operation.addParameter(param); continue; } if (apiParam != null && requestBody != null && isSimpleArray(parameter.getType())) { BodyParameter param = new BodyParameter(); param.setRequired(requestBody.required()); param.setDescription(apiParam.description()); param.setName("body"); ArrayModel model = new ArrayModel(); StringProperty property = new StringProperty(); property.setType(lookupType(parameter.getType())); property.setFormat(lookupFormat(parameter.getType(), apiParam)); model.setItems(property); param.setSchema(model); operation.addParameter(param); continue; } if (apiParam != null && requestBody != null && isSimpleScalar(parameter.getType())) { BodyParameter param = new BodyParameter(); param.setRequired(requestBody.required()); param.setDescription(apiParam.description()); param.setName("body"); ModelImpl model = new ModelImpl(); model.setType(lookupType(parameter.getType())); model.setFormat(lookupFormat(parameter.getType(), apiParam)); param.setSchema(model); operation.addParameter(param); continue; } if (apiParam != null && requestBody != null && isModelArray(parameter.getType())) { BodyParameter param = new BodyParameter(); param.setRequired(requestBody.required()); param.setDescription(apiParam.description()); param.setName("body"); ArrayModel model = new ArrayModel(); RefProperty property = new RefProperty(); property.setType(lookupType(parameter.getType())); property.set$ref("#/definitions/" + parameter.getType().getComponentType().getSimpleName()); if (!modelStack.contains(parameter.getType().getComponentType())) { modelStack.push(parameter.getType().getComponentType()); } model.setItems(property); param.setSchema(model); operation.addParameter(param); continue; } if (apiParam != null && requestBody != null && isModelScalar(parameter.getType())) { BodyParameter param = new BodyParameter(); param.setRequired(requestBody.required()); param.setDescription(apiParam.description()); param.setName("body"); RefModel model = new RefModel(); model.set$ref( "#/definitions/" + parameter.getType().getSimpleName()); if (!modelStack.contains(parameter.getType())) { modelStack.push(parameter.getType()); } param.setSchema(model); operation.addParameter(param); continue; } } else if (requestMethod == RequestMethod.POST) { if (apiParam != null && requestParam != null && isSimpleArray(parameter.getType())) { FormParameter param = new FormParameter(); param.setRequired(requestParam.required()); param.setDescription(apiParam.description()); param.setType("array"); if (!"".equals(requestParam.value())) { param.setName(requestParam.value()); } if (!"".equals(requestParam.name())) { param.setName(requestParam.name()); } param.setItems(lookupProperty(parameter.getType(), requestParam, apiParam)); operation.addParameter(param); continue; } if (apiParam != null && requestParam != null && isSimpleScalar(parameter.getType())) { FormParameter param = new FormParameter(); param.setRequired(requestParam.required()); param.setDescription(apiParam.description()); param.setType(lookupType(parameter.getType())); param.setFormat(lookupFormat(parameter.getType(), apiParam)); if (!"".equals(requestParam.value())) { param.setName(requestParam.value()); } if (!"".equals(requestParam.name())) { param.setName(requestParam.name()); } operation.addParameter(param); continue; } if (apiParam != null && requestPart != null && isSimpleArray(parameter.getType())) { FormParameter param = new FormParameter(); param.setRequired(requestPart.required()); param.setDescription(apiParam.description()); param.setType("array"); if (!"".equals(requestPart.value())) { param.setName(requestPart.value()); } if (!"".equals(requestPart.name())) { param.setName(requestPart.name()); } param.setItems(lookupProperty(parameter.getType(), requestParam, apiParam)); operation.addParameter(param); continue; } if (apiParam != null && requestPart != null && isSimpleScalar(parameter.getType())) { FormParameter param = new FormParameter(); param.setRequired(requestPart.required()); param.setDescription(apiParam.description()); param.setType(lookupType(parameter.getType())); param.setFormat(lookupFormat(parameter.getType(), apiParam)); if (!"".equals(requestPart.value())) { param.setName(requestPart.value()); } if (!"".equals(requestPart.name())) { param.setName(requestPart.name()); } operation.addParameter(param); continue; } } } for (ApiResponse apiResponse : apiResponses.value()) { if (isSimpleScalar(apiResponse.response())) { if (apiResponse.array()) { Response response = new Response(); if (!"".equals(apiResponse.description())) { response.setDescription( apiResponse.httpStatus().getReasonPhrase()); } else { response.setDescription(apiResponse.description()); } ArrayProperty property = new ArrayProperty(); property.setItems( lookupProperty(apiResponse.response(), apiResponse)); response.setSchema(property); operation.addResponse( String.valueOf(apiResponse.httpStatus().value()), response); } else { Response response = new Response(); if ("".equals(apiResponse.description())) { response.setDescription( apiResponse.httpStatus().getReasonPhrase()); } else { response.setDescription(apiResponse.description()); } response.setSchema( lookupProperty(apiResponse.response(), apiResponse)); operation.addResponse( String.valueOf(apiResponse.httpStatus().value()), response); } } else if (isModelScalar(apiResponse.response())) { if (apiResponse.array()) { Response response = new Response(); if (!"".equals(apiResponse.description())) { response.setDescription( apiResponse.httpStatus().getReasonPhrase()); } else { response.setDescription(apiResponse.description()); } RefProperty property = new RefProperty(); property.set$ref( "#/definitions/" + apiResponse.response().getSimpleName()); if (!modelStack.contains(apiResponse.response())) { modelStack.push(apiResponse.response()); } ArrayProperty array = new ArrayProperty(); array.setItems(property); response.setSchema(array); operation.addResponse( String.valueOf(apiResponse.httpStatus().value()), response); } else { Response response = new Response(); if (!"".equals(apiResponse.description())) { response.setDescription( apiResponse.httpStatus().getReasonPhrase()); } else { response.setDescription(apiResponse.description()); } RefProperty property = new RefProperty(); property.set$ref( "#/definitions/" + apiResponse.response().getSimpleName()); if (!modelStack.contains(apiResponse.response())) { modelStack.push(apiResponse.response()); } response.setSchema(property); operation.addResponse( String.valueOf(apiResponse.httpStatus().value()), response); } } } } } } } } } } while (!modelStack.isEmpty()) { Class<?> scheme = modelStack.pop(); if (definitions.containsKey(scheme.getSimpleName())) { continue; } java.lang.reflect.Field[] fields = scheme.getDeclaredFields(); if (fields != null && fields.length > 0) { ModelImpl model = new ModelImpl(); model.setType("object"); for (Field field : fields) { ApiProperty apiProperty = field.getDeclaredAnnotation(ApiProperty.class); if (apiProperty != null) { if (apiProperty.array()) { Class<?> type = apiProperty.model(); ArrayProperty property = new ArrayProperty(); if (isSimpleScalar(type)) { property.setItems(lookupProperty(type, apiProperty)); } else if (isModelScalar(type)) { if (!definitions.containsKey(type.getSimpleName())) { modelStack.push(type); } RefProperty ref = new RefProperty(); ref.set$ref("#/definitions/" + type.getSimpleName()); property.setItems(ref); } model.addProperty(field.getName(), property); } else { Class<?> type = field.getType(); if (isSimpleScalar(type)) { model.addProperty(field.getName(), lookupProperty(type, apiProperty)); } else if (isModelScalar(type)) { if (!definitions.containsKey(type.getSimpleName())) { modelStack.push(type); } RefProperty ref = new RefProperty(); ref.set$ref("#/definitions/" + type.getSimpleName()); model.addProperty(field.getName(), ref); } } } } definitions.put(scheme.getSimpleName(), model); } } this.swagger = swagger; }