Skip to content

Configuration items

Complete configuration

ConfigurationVersionRequiredTypeDefaultDescription
outPathStringSpecify the output path of the document
serverUrlStringhttp://127.0.0.1Server address, when exporting postman it is recommended to set it to http:// for convenience and directly in postman Set environment variables. It is recommended to use serverEnv when exporting postman after 2.4.8 to avoid modifying the configuration during multiple exports.
serverEnv2.4.8StringServer address, when exporting postman it is recommended to set it to http:// to facilitate setting environment variables directly in postman. The configuration is changed to support postman export without globally modifying serverUrl
pathPrefix2.2.3StringSet the path prefix, such as configuring Servlet ContextPath.
isStrictBooleanWhether to enable strict mode. Strict mode will force code comments to be checked. When setting this item in 2.6.3 or later plug-in versions, if annotation errors are detected, the plug-in will be directly interrupted. White nested build cycles. For team use, it is recommended to set it to true to increase the annotation requirements for developers and improve the completeness of the documentation.
allInOneBooleanfalseWhether to merge documents into one file, true is generally recommended.
coverOldBooleanfalseWhether to overwrite old files, mainly used for Markdown file coverage.
createDebugPage2.0.1Booleanfalsesmart-doc supports creating an HTML document page with a debuggable interface similar to Swagger, only in AllInOne function in the mode. Starting from @2.0.1, for HTML documents, debug pages can be generated in both allInOne and non-allInOne modes.
packageFiltersStringController package filtering, multiple packages separated by English commas.
2.2.2 starts to use regular rules: com.test.controller.*
2.7.1 starts to support method level regular rules: com.test.controller.TestController.*
packageExcludeFiltersStringExclude subpackages for packageFilters, multiple packages are separated by English commas
Since 2.2.2, regular rules must be used: com.test.controller. res.*
md5EncryptedHtmlNameBooleanfalseUsed only if each Controller generates an HTML file.
styleStringCode Highlight settings based on highlight.js.
projectNameStringUsed only if each Controller generates an HTML file. If projectName is not set in smart-doc.json or in the plugin, starting from 2.3.4, the plugin automatically uses the projectName in pom as the default filling, so it does not need to be configured when using the plugin.
skipTransientField1.7.8BooleantrueDeprecated since 3.0.8. Use serializeRequestTransients andserializeResponseTransients instead. This configuration was used to skip the serialization of transient fields in request and response bodies.
serializeRequestTransients3.0.8BooleanfalseDetermines whether transient fields in request objects should be serialized. When set to true, transient fields will be included in the request serialization.
serializeResponseTransients3.0.8BooleanfalseDetermines whether transient fields in response objects should be serialized. When set totrue, transient fields will be included in the response serialization.
sortByTitle1.8.7BooleanfalseInterface sorting by title.
showAuthorBooleantrueWhether to display the interface author name.
requestFieldToUnderline1.8.7BooleanfalseAutomatically convert camel case input fields to underline format in the document.
responseFieldToUnderline1.8.7BooleanfalseAutomatically convert camelCase response fields to underline format in the document.
inlineEnum1.8.8BooleanfalseWhether to display the enumeration details in the parameter table.
recursionLimit1.8.8int7Set the number of recursive executions allowed to avoid some object parsing problems.
allInOneDocFileName1.9.0Stringindex.htmlIt only takes effect when all Controller of the project are configured to generate an HTML file.
requestExample1.9.0BooleantrueWhether to display request examples in the documentation.
responseExample1.9.0BooleantrueWhether to display response examples in the documentation.
urlSuffix2.1.0StringSupport url suffix of SpringMVC old project.
languageStringCHINESEInternationalization support for mock values.
displayActualType1.9.6BooleanfalseWhether to automatically display the short class name of the generic real type in the comment column.
appKey2.0.9Stringtorna platform connects to appKey.
appToken2.0.9Stringtorna platform appToken.
secret2.0.9Stringtorna platform secret.
openUrl2.0.9Stringtorna platform address, fill in your own private deployment address.
debugEnvNameStringtorna environment name.
replace2.2.4BooleantrueReplace old documents when pushing torna. Changes will still be pushed to the past and covered. This function is mainly to ensure that the code is deleted and not deleted on torna.
debugEnvUrl2.0.9StringPush torna configuration interface service address.
tornaDebug2.0.9BooleantrueWhether to print torna push log.
ignoreRequestParams1.9.2List<String>Ignore request parameter objects and block parameter objects that do not want to generate documents.
dataDictionariesList<Object>Configure data dictionary
Since 2.4.6, you can configure the interface implemented by the enumeration. When configuring the interface, the title will be used Description of the class that implements the enumeration. If there are already implemented enumerations that need to be ignored, you can add @ignore to the class that implements the enumeration to ignore them.
errorCodeDictionariesList<Object>Error code list
Since 2.4.6, the interface implemented by the enumeration can be configured. When configuring the interface, the title will be used Description of the class that implements the enumeration. If there are already implemented enumerations that need to be ignored, you can add @ignore to the class that implements the enumeration to ignore them.
revisionLogsList<Object>Document change record.
customResponseFieldsList<Object>Customize added fields and comments, general users deal with third-party jar package libraries.
customRequestFieldsList<Object>Comments for the custom request body.
requestHeaders2.1.3List<Object>Set public request headers.
requestParams2.2.3List<Object>Public request parameters (scenarios handled by interceptors).
rpcApiDependenciesList<Object>The project's open Dubbo API interface module depends on it. After configuration, it is output to the document to facilitate user integration.
rpcConsumerConfigStringThe Dubbo Consumer integration configuration is added to the document to facilitate quick integration by the integrator.
apiObjectReplacements1.8.5List<Object>Use custom classes to override other classes for document rendering.
apiConstants1.8.9List<Object>Configure your own constant class, smart-doc resolves to constants automatically replaced with a specific value. Starting from 2.4.2 version, there is no need to configure constants when using them. smart-doc can already be automatically parsed.
responseBodyAdvice1.8.9List<Object>ResponseBodyAdvice is a hook reserved in the Spring framework, which acts after the execution of the Controller method is completed After that, before the http response body is written back to the client, it can easily weave in some of its own business logic processing, so smart-doc also provides unified return settings for ResponseBodyAdvice (do not configure it casually according to the project technology to configure) support, which can be ignored using the ignoreResponseBodyAdvice tag.
requestBodyAdvice2.1.4List<Object>Set the RequestBodyAdvice unified request wrapper class.
groups2.2.5List<Object>Group different Controllers.
requestParamsTable2.2.5StringWhether to display the request parameter table in the document.
responseParamsTable2.2.5BooleanWhether to display the response parameter table in the document.
framework2.2.5Stringspring or dubboSpring and Apache Dubbo are frameworks that support parsing and generating documents by smart-doc by default and are not configured framework automatically selects Spring or Dubbo according to the triggered document construction scenario. smart-doc currently also supports the JAX-RS standard, so use a framework that supports the JAX-RS standard (such as: Quarkus) can be used as an experience, but it is not complete yet.
Optional values: spring, dubbo, JAX-RS, solon
randomMock2.6.9BooleanfalserandomMock is used to control whether smart-doc generates random mock values, in versions before 2.6.9 smart-doc will automatically assign parameters and automatically generate random values. The generated values are different each time. Now you can set it to false to control the generation of random values.
componentType2.7.8StringRANDOMopenapi component key generator
RANDOM: supports @Validated group verification
NORMAL : Does not support @Validated, used for openapi generated code
apiUploadNums3.0.2IntegerWhen uploading Torna, batch uploading of documents is supported, and the size of document batches can be set.
showValidation3.0.3BooleantrueshowValidation is used to control whether smart-doc extracts the JSR validation information of fields for display in the documentation.
jmeter3.0.4ObjectCustom Configurations for JMeter Performance Test Script Generation
addDefaultHttpStatuses3.0.5BooleanfalseWhen generating documentation, consider whether to include the default HTTP status codes from frameworks such as Spring MVC's default 500 and 404 errors. Currently, only the generation of OpenAPI documentation supports this feature.
json
{
    "serverUrl": "http://127.0.0.1",
    "serverEnv": "http://{{server}}",
    "pathPrefix": "",
    "isStrict": false,
    "allInOne": true,
    "outPath": "D://md2",
    "randomMock": false,
    "coverOld": true,
    "createDebugPage": true,
    "packageFilters": "",
    "packageExcludeFilters": "",
    "md5EncryptedHtmlName": false,
    "style": "xt256",
    "projectName": "smart-doc",
    "framework": "spring",
    "skipTransientField": true,
    "serializeRequestTransients": false,
    "serializeResponseTransients": false,
    "sortByTitle": false,
    "showAuthor": true,
    "requestFieldToUnderline": true,
    "responseFieldToUnderline": true,
    "inlineEnum": true,
    "recursionLimit": 7,
    "allInOneDocFileName": "index.html",
    "requestExample": "true",
    "responseExample": "true",
    "requestParamsTable": true,
    "responseParamsTable": true,
    "urlSuffix": ".do",
    "displayActualType": false,
    "appToken": "c16931fa6590483fb7a4e85340fcbfef",
    "isReplace": true,
    "openUrl": "http://localhost:7700/api",
    "debugEnvName": "Test ENV",
    "debugEnvUrl": "http://127.0.0.1",
    "tornaDebug": false,
    "author": "smart-doc",
    "increment": false,
    "ignoreRequestParams": [
        "org.springframework.ui.ModelMap"
    ],
    "dataDictionaries": [
        {
            "title": "http status",
            "enumClassName": "com.power.common.enums.HttpCodeEnum",
            "codeField": "code",
            "descField": "message"
        },
        {
            "enumClassName": "com.xx.IEnum",
            "codeField": "code",
            "descField": "message"
        }
    ],
    "errorCodeDictionaries": [
        {
            "title": "title",
            "enumClassName": "com.power.common.enums.HttpCodeEnum",
            "codeField": "code",
            "descField": "message",
            "valuesResolverClass": ""
        },
        {
            "enumClassName": "com.xx.IEnum",
            "codeField": "code",
            "descField": "message"
        }
    ],
    "revisionLogs": [
        {
            "version": "1.0",
            "revisionTime": "2020-12-31 10:30",
            "status": "update",
            "author": "author",
            "remarks": "desc"
        }
    ],
    "customResponseFields": [
        {
            "name": "code",
            "desc": "response code",
            "ownerClassName": "org.springframework.data.domain.Pageable",
            "ignore": true,
            "value": "00000"
        }
    ],
    "customRequestFields": [
        {
            "name": "code",
            "desc": "status code",
            "ownerClassName": "com.xxx.constant.entity.Result",
            "value": "200",
            "required": true,
            "ignore": false
        }
    ],
    "requestHeaders": [
        {
            "name": "token",
            "type": "string",
            "desc": "desc",
            "value": "token value",
            "required": false,
            "since": "-",
            "pathPatterns": "/app/test/**",
            "excludePathPatterns": "/app/page/**"
        },
        {
            "name": "appkey",
            "type": "string",
            "desc": "desc",
            "value": "appkey value",
            "required": false,
            "pathPatterns": "/test/add,/testConstants/1.0",
            "since": "-"
        }
    ],
    "requestParams": [
        {
            "name": "configPathParam",
            "type": "string",
            "desc": "desc",
            "paramIn": "path",
            "value": "testPath",
            "required": false,
            "since": "-",
            "pathPatterns": "**",
            "excludePathPatterns": "/app/page/**"
        },
        {
            "name": "configQueryParam",
            "type": "string",
            "desc": "desc",
            "paramIn": "query",
            "value": "testQuery",
            "required": false,
            "since": "-",
            "pathPatterns": "**",
            "excludePathPatterns": "/app/page/**"
        }
    ],
    "rpcApiDependencies": [
        {
            "artifactId": "SpringBoot2-Dubbo-Api",
            "groupId": "com.demo",
            "version": "1.0.0"
        }
    ],
    "rpcConsumerConfig": "src/main/resources/consumer-example.conf",
    "apiObjectReplacements": [
        {
            "className": "org.springframework.data.domain.Pageable",
            "replacementClassName": "com.power.doc.model.PageRequestDto"
        }
    ],
    "apiConstants": [
        {
            "constantsClassName": "com.power.doc.constants.RequestParamConstant"
        }
    ],
    "responseBodyAdvice": {
        "className": "com.power.common.model.CommonResult"
    },
    "requestBodyAdvice": {
        "className": "com.power.common.model.CommonResult"
    },
    "groups": [
        {
            "name": "test group",
            "apis": "com.power.doc.controller.app.*"
        }
    ],
    "requestParamsTable": true,
    "responseParamsTable": true,
    "componentType": "RANDOM",
    "jmeter": {
        "addPrometheusListener": true
    },
    "addDefaultHttpStatuses": true
}

packageFilters

Controller packet filtering, multiple packets are separated by commas.

PS: Starting from 2.2.2, you need to use regular rules: com.test.controller., and starting from 2.7.1, you need to use method-level regular rules: com.test.controller.TestController.

json
{
    "packageFilters": "com.test.controller.*", // Output all interfaces under the controller package
    "packageFilters": "com.example.controller.PetController", // Only output the interface of PetController
    "packageFilters": "com.example.controller.*Controller", // Output all interfaces under the controller package with the Controller suffix as the class name
    "packageFilters": "com.example.controller.Pet.*", // Output all interfaces under the controller package that have class names starting with Pet
    "packageFilters": "com.example.controller.Pet.*Controller", // Output all interfaces under the controller package that match the Pet*Controller class name
    "packageFilters": "com.example.controller.PetController.getPetInfo", // Output the getPetInfo method interface in PetController
    "packageFilters": "com.example.controller.PetController.*", // Output all interfaces in PetController
    "packageFilters": "com.example.controller.PetController.get.*", // Only output all interfaces in the PetController class that start with get as the method name
    "packageFilters": "com.example.controller.PetController.*Info", //Only output all interfaces in the PetController class whose method names end with Info
    "packageFilters": "com.example.controller.PetController.get.*Info", //Only output all interfaces in the PetController class that match get.*Info as the method name
}

dataDictionaries

Configure the data dictionary. Starting from 2.4.6, you can configure the interface implemented by the enumeration. When configuring the interface, title will use the class description that implements the enumeration. If there are already implemented enumerations that need to be ignored, you can implement the enumeration. Add @ignore to the class to ignore it.

ConfigurationTypeDescription
titleString
enumClassNameStringError code enumeration class
codeFieldStringThe name of the code code field of the error code. By default, smart-doc uses the getCode method name to obtain it through reflection. If there is no get method, you can configure the corresponding method name of the field, for example: code().
descFieldStringThe field name corresponding to the error code description information. Like codeField, it can be configured as a method name, for example: message()
json
{
    "dataDictionaries": [
        {
            "title": "title",
            "enumClassName": "com.power.common.enums.HttpCodeEnum", 
            "codeField": "code", 
            "descField": "message" 
        }
    ]
}

errorCodeDictionaries

Error code list, starting from 2.4.6, you can configure the interface implemented by the enumeration. When configuring the interface, title will use the class description that implements the enumeration. If there are already implemented enumerations that need to be ignored, you can implement the enumeration. Add @ignore to the class to ignore it.

ConfigurationTypeDescription
titleString
enumClassNameStringError code enumeration class
codeFieldStringThe name of the code code field of the error code. By default, smart-doc uses the getCode method name to obtain it through reflection. If there is no get method, you can configure the corresponding method name of the field, for example: code().
descFieldStringThe field name corresponding to the error code description information. Like codeField, it can be configured as a method name, for example: message()
json
{
    "errorCodeDictionaries": [
        {
            "title": "title",
            "enumClassName": "com.power.common.enums.HttpCodeEnum", 
            "codeField": "code", 
            "descField": "message" 
        }
    ]
}

revisionLogs

Documentation change history.

ConfigurationTypeDescription
versionStringDocument version number
revisionTimeStringDocument revision time
statusStringChange operation status, usually: create, update, etc.
authorStringDocument change author
remarksStringChange description
json
{
    "revisionLogs": [
        {
            "version": "1.0", 
            "revisionTime": "2020-12-31 10:30", 
            "status": "update", 
            "author": "author", 
            "remarks": "desc" 
        }
    ]
}

customResponseFields

Customize added fields and comments, and general users deal with third-party jar package libraries.

ConfigurationTypeDescription
nameStringOverride response code field
descStringField comments that override the response code
ownerClassNameStringSpecify the class name you want to annotate
ignoreBooleanSetting true will be automatically ignored and will not appear in the document
valueStringSet the value of the response code
json
{
    "customResponseFields": [
        {
            "name": "code", 
            "desc": "response code", 
            "ownerClassName": "org.springframework.data.domain.Pageable",
            "ignore": true, 
            "value": "00000" 
        }
    ]
}

customRequestFields

Customize added fields and comments, and general users deal with third-party jar package libraries.

ConfigurationTypeDescription
nameStringProperty name
descStringDescription
ownerClassNameStringThe full path of the class corresponding to the attribute
ignoreBooleanWhether to ignore
requiredBooleanIs it required
valueStringDefault value or mock value
json
{
    "customRequestFields": [
        {
            "name": "code", 
            "desc": "code", 
            "ownerClassName": "com.xxx.constant.entity.Result",
            "value": "200", 
            "required": true, 
            "ignore": false 
        }
    ]
}

rpcApiDependencies

The open Dubbo API interface module of the project depends on it. After configuration, it is output to the document to facilitate user integration.

ConfigurationTypeDescription
artifactIdStringartifactId
groupIdStringgroupId
versionStringVersion number
json
{
    "rpcApiDependencies": [
        {
            "artifactId": "SpringBoot2-Dubbo-Api",
            "groupId": "com.demo",
            "version": "1.0.0"
        }
    ]
}

apiObjectReplacements

Use custom classes to override other classes for document rendering.

ConfigurationTypeDescription
classNameStringThe full class name that needs to be replaced
replacementClassNameStringThe fully qualified class name to be replaced
json
{
    "apiObjectReplacements": [
        {
            "className": "org.springframework.data.domain.Pageable",
            "replacementClassName": "com.power.doc.model.PageRequestDto" //自定义的PageRequestDto替换Pageable做文档渲染
        }
    ]
}

responseBodyAdvice

ResponseBodyAdvice is a hook reserved in the Spring framework. It acts after the Controller method is executed and before the http response body is written back to the client. It can conveniently weave in some of its own business logic processing. Therefore, smart-doc also provides support for unified return settings of ResponseBodyAdvice (do not configure it casually according to the technology of the project), which can be ignored by ignoreResponseBodyAdvice tag.

ConfigurationTypeDescription
classNameStringUniversal response body
json
{
    "responseBodyAdvice": {
        "className": "com.power.common.model.CommonResult" 
    }
}

requestBodyAdvice

Set the RequestBodyAdvice unified request wrapper class.

ConfigurationTypeDescription
classNameStringUniversal request body
json
{
    "requestBodyAdvice": {
        "className": "com.power.common.model.CommonResult" 
    }
}

groups

Group different Controllers.

PS: Grouping does not take effect on postman.json and openApi.json

ConfigurationTypeDescription
nameStringGroup name
apisStringGroup url, supports regular expressions,with multiple expressions separated by commas
json
{
  "groups": [
    {
      "name": "Test Group",
      "apis": "com.example.controller.*",
      "apis": "com.example.controller.PetController", // Contains only the interface of PetController
      "apis": "com.example.controller.Controller", // Contains all interfaces under the controller package with a class name suffixed by Controller
      "apis": "com.example.controller.Pet.", // Contains all interfaces under the controller package with a class name starting with Pet
      "apis": "com.example.controller.Pet.Controller" // Contains all interfaces under the controller package that match the class name PetController
    }
  ]
}

If the apis configuration does not take effect in templates that support grouping, there might be an issue with the regular expression configuration. You can validate this using the DocUtil tool in smart-doc.

Here is an example of how to verify:

@Test
public void testIsMatch() {
    String pattern = "com.aaa.*.controller";
    String controllerName = "com.aaa.cc.controlle";
    System.out.println(DocUtil.isMatch(pattern, controllerName));
}

jmeter

Starting from version 3.0.4, the following custom configuration options have been added when generating JMeter performance test scripts:

ConfigurationTypeDescription
addPrometheusListenerBooleanWhether to add a Prometheus listener when generating the script
json
{
  "jmeter": {
    "addPrometheusListener": true
  }
}

Released under the MIT License.