gpt4 book ai didi

swagger - 如何使用 Swagger Codegen 生成具有数据类型为 Currency(java.util) 的变量的模型

转载 作者:行者123 更新时间:2023-12-01 03:20:03 25 4
gpt4 key购买 nike

有没有办法使用 Swagger Codegen 生成具有数据类型为 Currency(java.util) 的变量的模型?

注意:我使用 Swagger 2.0 版和 Swagger Codegen 2.2.3 版

最佳答案

您可以定义一个 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-mapping‌​s>
</configOptions>

关于swagger - 如何使用 Swagger Codegen 生成具有数据类型为 Currency(java.util) 的变量的模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46180810/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com