001/** 002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com). 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package io.jboot.apidoc; 017 018import com.jfinal.kit.PathKit; 019import com.jfinal.kit.Ret; 020import io.jboot.utils.FileUtil; 021 022import java.io.File; 023 024public class ApiDocConfig { 025 026 private String basePath = "apidoc"; 027 private String packagePrefix; 028 029 030 private boolean allInOneEnable = false; 031 private String allInOneTitle = "Api Document"; 032 private String allInOneNotes; 033 private String allInOneFilePath = "apidoc"; 034 035 private String mockJsonPath = "api-mock.json"; 036 private String remarksJsonPath = "api-remarks.json"; 037 038 private Class<?> defaultContainerClass = Ret.class; 039 040 041 public String getBasePath() { 042 return basePath; 043 } 044 045 public String getBasePathAbsolute() { 046 if (FileUtil.isAbsolutePath(basePath)) { 047 return basePath; 048 } 049 return FileUtil.getCanonicalPath(new File(PathKit.getRootClassPath(), "../../" + basePath)); 050 } 051 052 public void setBasePath(String basePath) { 053 this.basePath = basePath; 054 } 055 056 public String getPackagePrefix() { 057 return packagePrefix; 058 } 059 060 public void setPackagePrefix(String packagePrefix) { 061 this.packagePrefix = packagePrefix; 062 } 063 064 065 public boolean isAllInOneEnable() { 066 return allInOneEnable; 067 } 068 069 public void setAllInOneEnable(boolean allInOneEnable) { 070 this.allInOneEnable = allInOneEnable; 071 } 072 073 public String getAllInOneTitle() { 074 return allInOneTitle; 075 } 076 077 public void setAllInOneTitle(String allInOneTitle) { 078 this.allInOneTitle = allInOneTitle; 079 } 080 081 public String getAllInOneNotes() { 082 return allInOneNotes; 083 } 084 085 public void setAllInOneNotes(String allInOneNotes) { 086 this.allInOneNotes = allInOneNotes; 087 } 088 089 public String getAllInOneFilePath() { 090 return allInOneFilePath; 091 } 092 093 public void setAllInOneFilePath(String allInOneFilePath) { 094 this.allInOneFilePath = allInOneFilePath; 095 } 096 097 public String getMockJsonPath() { 098 return mockJsonPath; 099 } 100 101 public void setMockJsonPath(String mockJsonPath) { 102 this.mockJsonPath = mockJsonPath; 103 } 104 105 public String getMockJsonPathAbsolute() { 106 if (FileUtil.isAbsolutePath(mockJsonPath)) { 107 return mockJsonPath; 108 } 109 return new File(PathKit.getRootClassPath(), mockJsonPath).getAbsolutePath(); 110 } 111 112 public String getRemarksJsonPath() { 113 return remarksJsonPath; 114 } 115 116 public void setRemarksJsonPath(String remarksJsonPath) { 117 this.remarksJsonPath = remarksJsonPath; 118 } 119 120 public String getRemarksJsonPathAbsolute() { 121 if (FileUtil.isAbsolutePath(remarksJsonPath)) { 122 return remarksJsonPath; 123 } 124 return new File(PathKit.getRootClassPath(), remarksJsonPath).getAbsolutePath(); 125 } 126 127 public Class<?> getDefaultContainerClass() { 128 return defaultContainerClass; 129 } 130 131 public void setDefaultContainerClass(Class<?> defaultContainerClass) { 132 this.defaultContainerClass = defaultContainerClass; 133 } 134}