方法一 使用浏览器
[https://generator.swagger.io/#!/clients/generateClient](https://generator.swagger.io/#!/clients/generateClient)
{
"spec": {},
"options": {},
"swaggerUrl": "Your Swagger URL",
"authorizationValue": {
"value": "",
"type": "“,
"keyName": ""
},
"securityDefinition": {
"type": "",
"description": ""
}
}
方法二 配置codegen(不用online)
下载安装jdk
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
export PATH=${JAVA_HOME}/bin:$PATH
下载codegen
git clone https://github.com/swagger-api/swagger-codegen
cd swagger-codegen
下载maven,执行
mvn clean package
这样就可以生成了
cd swagger-codegen
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l php \
-o /var/tmp/php_api_client
cd swagger-codegen
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://192.168.41.150:9001/swagger/docs/v1 \
-l android \
-o ~/abc
网友评论