我在 gradle 中使用 swagger codegen cli 工具(版本 3.0.25)生成一个 java 客户端:
task doCodeGenSdk(type: JavaExec) {
main = "io.swagger.codegen.v3.Codegen"
classpath = configurations.codeGenCli
inputs.files file("${swaggerSpecDir}/*.json")
outputs.dir file("${codeGenDirSdk}")
args = ["generate", "--lang", "java", "--input-spec", "${swaggerSpecFile}",
"--config", "${swaggerConfig}",
"--template-dir", "${swaggerTemplateDir}",
"--output", "${codeGenDirSdk}"]
systemProperty "apiTests", "false"
systemProperty "apiDocs", "false"
systemProperty "modelTests", "false"
systemProperty "modelDocs", "false"}
Run Code Online (Sandbox Code Playgroud)
swagger配置文件如下所示:
{
"library": "resttemplate",
"artifactVersion": "__VERSION__",
"artifactId": "__ARTIFACT_ID__",
"modelPackage": "com.model",
"apiPackage": "com.api",
"invokerPackage": "com.invoker",
"dateLibrary": "java8",
"apiTests": false,
"java8": true,
"serializableModel": true,
"useBeanValidation": true,
"performBeanValidation": true}
Run Code Online (Sandbox Code Playgroud)
模板目录具有以下胡子文件:
ApiClient.mustache, generatedAnnotation.mustache, licenseInfo.mustach, pojo.mustache …Run Code Online (Sandbox Code Playgroud) 我正在尝试根据它们之间的空格在python中排序字符串列表.例如,如果字符串列表是{'hello world', 'hello', 'hello world again', 'hello there'}.
在排序之后,列表应包含第一个位置中空格数最多的字符串,其后包含其他字符串:
{'hello world again', 'hello world', 'hello there', 'hello'}.
Run Code Online (Sandbox Code Playgroud)
此致,Alok