gpt4 book ai didi

c# - Swagger Api 文档 - 模型列表<枚举>

转载 作者:行者123 更新时间:2023-11-30 18:33:30 29 4
gpt4 key购买 nike

应该如何为 Swagger 建模这个类?正确解释它?

public myEnum {
alpha,
bravo,
charlie
}

public class myClass {
public List<myEnum> myList { get; set; }
}

我不能简单地这样做:

{
"myClass": {
"id": "myClass",
"properties": {
"myList": {
"type": "string", //??? it isn't a string, it's a List...
"allowableValues": {
"valueType": "LIST",
"values": [
"alpha",
"bravo",
"charlie"
]
}
}
}
}
}

这也没有意义:

{
"myEnum": {
"id": "myEnum",
"properties": {
//??? there aren't any...
}
},
"myClass": {
"id": "myClass",
"properties": {
"myList": {
"type": "List",
"items": {
"$ref": "myEnum"
}
}
}
}
}

最佳答案

遇到了this post in the Swagger Google Group ,这让我得到了这个答案:

{
"myClass": {
"id": "myClass",
"properties": {
"myList": {
"type": "List",
"items": {
"type": "string"
},
"allowableValues": {
"valueType": "LIST",
"values": [
"alpha",
"bravo",
"charlie"
]
}
}
}
}
}

关于c# - Swagger Api 文档 - 模型列表<枚举>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17532974/

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