@PostConstruct public void afterCreate() { BufferedImage image = getLogo(); BufferedImage image16 = getFavicon(16, image); BufferedImage image32 = getFavicon(32, image); try { this.originalLogo = toBytes(image); log.finest("OpenApi UI: Created logo"); this.favicon16 = toBytes(image16); this.favicon32 = toBytes(image32); log.finest("OpenApi UI: Created favicons"); } catch (IOException ex) { log.log(Level.SEVERE, null, ex); } this.style = getCss(); }
public byte[] getFavicon(int size){ if(size>24)return getFavicon32(); return getFavicon16(); }
private String getContextRoot(UriInfo uriInfo,HttpServletRequest request){ if(contextRoot==null || contextRoot.isEmpty()){ return getOriginalContextPath(uriInfo,request); } return contextRoot; }
private String parseHtmlTemplate(UriInfo uriInfo, HttpServletRequest request){ String html = getHTMLTemplate(); html = html.replaceAll(VAR_CONTEXT_ROOT, getContextRoot(uriInfo,request)); html = html.replaceAll(VAR_CURRENT_YEAR, getCopyrightYear()); // Dynamic whitelabel properties. try { Iterable<String> propertyNames = config.getPropertyNames(); for(String key: propertyNames){ if(key.startsWith(KEY_IDENTIFIER) && !isKnownProperty(key)){ String htmlKey = PERSENTAGE + key + PERSENTAGE; html = html.replaceAll(htmlKey, config.getValue(key,String.class)); } } }catch(UnsupportedOperationException uoe){ log.log(Level.WARNING, "Can not replace dynamic properties in the Open API Swagger template. {0}", uoe.getMessage()); } // Then properties with defaults. html = html.replaceAll(VAR_COPYRIGHT_BY, copyrightBy); html = html.replaceAll(VAR_TITLE, title); html = html.replaceAll(VAR_SWAGGER_THEME, swaggerUiTheme); html = html.replaceAll(VAR_SERVER_INFO, getServerInfo(request)); return html; }
@GET @Produces("image/png") @Path("favicon-{size}.png") @Operation(hidden = true) public byte[] getFavicon(@PathParam("size") int size){ return templates.getFavicon(size); }
private String getOriginalContextPath(UriInfo uriInfo,HttpServletRequest request){ String fromHeader = request.getHeader(X_REQUEST_URI); if(fromHeader!=null && !fromHeader.isEmpty()){ return getContextPathPart(uriInfo,request,fromHeader); } return request.getContextPath(); }
private String parseHtmlTemplate(UriInfo uriInfo, HttpServletRequest request){ String html = getHTMLTemplate(); html = html.replaceAll(VAR_CONTEXT_ROOT, getContextRoot(uriInfo,request)); html = html.replaceAll(VAR_CURRENT_YEAR, getCopyrightYear()); // Dynamic whitelabel properties. try { Iterable<String> propertyNames = config.getPropertyNames(); for(String key: propertyNames){ if(key.startsWith(KEY_IDENTIFIER) && !isKnownProperty(key)){ String htmlKey = PERSENTAGE + key + PERSENTAGE; html = html.replaceAll(htmlKey, config.getValue(key,String.class)); } } }catch(UnsupportedOperationException uoe){ log.log(Level.WARNING, "Can not replace dynamic properties in the Open API Swagger template. {0}", uoe.getMessage()); } // Then properties with defaults. html = html.replaceAll(VAR_COPYRIGHT_BY, copyrightBy); html = html.replaceAll(VAR_TITLE, title); html = html.replaceAll(VAR_SWAGGER_THEME, swaggerUiTheme); html = html.replaceAll(VAR_SERVER_INFO, getServerInfo(request)); return html; }
@GET @Produces("image/png") @Path("favicon-{size}.png") @Operation(hidden = true) public byte[] getFavicon(@PathParam("size") int size){ return templates.getFavicon(size); }
private String getOriginalContextPath(UriInfo uriInfo,HttpServletRequest request){ String fromHeader = request.getHeader(X_REQUEST_URI); if(fromHeader!=null && !fromHeader.isEmpty()){ return getContextPathPart(uriInfo,request,fromHeader); } return request.getContextPath(); }
@PostConstruct public void afterCreate() { BufferedImage image = getLogo(); BufferedImage image16 = getFavicon(16, image); BufferedImage image32 = getFavicon(32, image); try { this.originalLogo = toBytes(image); log.finest("OpenApi UI: Created logo"); this.favicon16 = toBytes(image16); this.favicon32 = toBytes(image32); log.finest("OpenApi UI: Created favicons"); } catch (IOException ex) { log.log(Level.SEVERE, null, ex); } this.style = getCss(); }
public byte[] getFavicon(int size){ if(size>24)return getFavicon32(); return getFavicon16(); }
private String getContextRoot(UriInfo uriInfo,HttpServletRequest request){ if(contextRoot==null || contextRoot.isEmpty()){ return getOriginalContextPath(uriInfo,request); } return contextRoot; }