在Debian系统上,可以使用多种工具来测试和验证Swagger API文档。以下是一些推荐的工具及其使用方法:
pom.xml
文件中添加Springfox Swagger的依赖。@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.example.controller"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Swagger API Documentation")
.description("API documentation for our Spring Boot application")
.version("1.0")
.build();
}
}
# 扫描单域名
python apidetector.py -d example.com
# 扫描单文件多域名
python apidetector.py -i input_file.txt
# 指定输出
python apidetector.py -i input_file.txt -o output_file.txt
# 使用特定数量的线程
python apidetector.py -i input_file.txt -t 20
# 使用HTTP和HTTPS协议扫描
python apidetector.py -m -d example.com
# 在安静模式下运行脚本
python apidetector.py -q -d example.com
# 使用自定义用户代理运行脚本
python apidetector.py -d example.com -ua "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"
const express = require('express');
const swaggerUi = require('swagger-ui-express');
const YAML = require('yamljs');
// Load Swagger document
const swaggerDocument = YAML.load('./swagger.json');
const app = express();
// Serve Swagger docs
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
// Start the server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running at http://localhost:${PORT}/api-docs`);
});
这些工具可以帮助你在Debian系统上有效地测试和验证Swagger API文档,确保API的功能和性能符合预期。