有没有办法生成具有Swagger Codegen数据类型为Currency(java.util)的变量的模型?
注意:我使用Swagger版本2.0和Swagger Codegen版本2.2.3
答案 0 :(得分:2)
您可以在规范中定义Currency
对象,然后使用--import-mappings
来避免为其创建模型。
(部分)规范:
definitions:
Bill:
type: "object"
properties:
id:
type: "integer"
format: "int64"
category:
$ref: "#/definitions/Currency"
Currency:
type: "object"
命令:
java -jar swagger-codegen-cli.jar generate -l java -i MySpec.yaml --import-mappings Currency=java.util.Currency
或者,如果您使用的是Maven,请将其添加到pom.xml
:
<configOptions>
<import-mappings>Currency=java.util.Currency</import-mappings>
</configOptions>