Service Configuration
Example
{
"name": "product",
"token": "682db6370f3148479cdf3232432dfsfd",
"source": "http://localhost:9002/swagger-json",
"version": 3,
"enabled": true,
"returnLevel": "second",
"returnSecondField": "data",
"tagNameMap": {
"User Management": "User",
"User Authentication": "Auth",
"Application Management": "Application"
}
}
Parameter Description
code
- Type: string
The service code, configured in the console.
Note: When generating APIs, directories will be created based on the application's output directory and the service code. All API files for the service will be placed in this directory. For example, if the application's output directory is ./src/api/auto
and the service code is product
, the final generation directory will be ./src/api/auto/product
name
- Type: string
The service name, configured in the console.
token
- Type: string
The service token, automatically generated after creating a service in the console.
source
- Type: string
- Supports online files, e.g.,
https://***/swagger.json
- Supports local files (relative path), e.g.,
./**/swagger.json
The Swagger address, supporting both local files and online files.
version
- Type: number
- Optional values:
2|3
The Swagger version, currently supporting Swagger/AutoAPI 2.x/3.x.
enabled
- Type: boolean
- Default: true
- Optional values:
true|false
Whether the current service is enabled. When disabled, the current service will be excluded when generating APIs. Other services under the current application are not affected.
returnLevel
- Type: string
- Default: 'second'
- Optional values:
'second'|'first'
The structural level of the generated API response message. Since interfaces typically return the following structure during processing:
{
"status" : 0,
"message" : "OK",
"data" : {
xxx:xxx
}
}
The first-level structure is often handled uniformly through interface interceptors (such as error prompts), so only the second-level structure needs to be processed. Therefore, this parameter defaults to second
.
returnSecondField
- Type: string
- Only valid when
returnLevel
issecond
The specified field when generating the second-level structure of the API response message.
Since user-returned results are not uniform, this field needs to be specified.
Example
When the interface returns the following structure:
{
"status" : 0,
"message" : "OK",
"data" : {
xxx:xxx
}
}
At this time, returnSecondField
can be specified as data
tagNameMap
- Type: object
Mapping for Swagger group identifier Tag
.
If the Tags are not friendly for generating API files, users need to specify this here to generate more readable API files. If not specified, the original Tag name will be used for generation.
Example:
{
"tagNameMap": {
"User Management": "User",
"User Authentication": "Auth",
"Application Management": "Application"
}
}
The generated API documentation is as follows: