作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想创建一个包含 MSON 格式对象的嵌套数组,以便与 API Blueprint 和 Apiary 一起使用。我的代码看起来是正确的,但是当我在 Apiary 中渲染它时,我没有得到预期的 JSON。
我要创建的示例:导航有多个类别。每个类别可以有多个子类别。每个类别和子类别都有一个名称。
我为此创建的 MSON:
FORMAT: 1A
# Test nested arrays-in-object-arrays
A navigation has multiple categories. Each category can have multiple subcategories.
# GET /navigation
+ Response 200 (application/json)
+ Attributes
+ categories (array)
+ (object)
+ name: Category One (string) - Name of the category
+ subcategories (array)
+ (object)
+ name: Sub category One (string) - Name of the subcategory
我期望的 JSON 输出:
{
"categories": [
{
"name": "Category One",
"subcategories":
[
{
"name": "Sub category One"
}
]
}
]
}
我在 Apiary 中得到的输出
{
"categories": [
{
"name": "Category One",
"subcategories": []
}
]
}
最佳答案
我在做类似的事情时遇到了困难。我最终将嵌套类型声明为数据结构并像这样引用它:
FORMAT: 1A
# Test nested arrays-in-object-arrays
A navigation has multiple categories. Each category can have multiple subcategories.
# GET /navigation
+ Response 200 (application/json)
+ Attributes
+ categories (array)
+ (object)
+ name: Category One (string) - Name of the category
+ subcategories (array[subcategory])
# Data Structures
## subcategory (object)
+ name: Sub category One (string) - Name of the subcategory
产生:
{
"categories": [
{
"name": "Category One",
"subcategories": [
{
"name": "Sub category One"
}
]
}
]
}
关于json - MSON 中带有对象的嵌套数组在 Apiary.io 文档中为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30890933/
我正在使用 API Blueprint和 Agilo呈现我的 API 文档。使用枚举类型时,我观察到一种奇怪的行为。响应未显示定义的枚举值,而架构显示所有枚举值(这是预期的)以及声明的值(“星期一”-
我正在研究 API Blueprint 中新数据结构语法的可能性,尤其是 MSON。是否可以附加或者更确切地说指定诸如模式(正则表达式)之类的东西?未找到有关此主题的任何内容。 最佳答案 要为您的数据
我想创建一个包含 MSON 格式对象的嵌套数组,以便与 API Blueprint 和 Apiary 一起使用。我的代码看起来是正确的,但是当我在 Apiary 中渲染它时,我没有得到预期的 JSON
我是一名优秀的程序员,十分优秀!