如何访问 RAML 文件中的请求类型使用 webapi-parser

问题描述

使用的库 webapi-parser 0.5.0

使用的语言库 爪哇

描述问题 我找不到访问 raml 文件中定义的请求类型的方法

输入有问题 下面是 RAML 文件的相关部分

/testEndpoint:
      type: rt.Item
      post:
        is: [t.ReturnsItemCreated,t.ExpectsContext,t.ReturnsNotFound,t.ReturnsBadGateway,t.ReturnsCommonErrors,t.NotCacheable]
        body:
          application/json:
            type: bu.BlockCodeUpdatesRequestType
            examples:
              de-cards-bc: !include examples/example1.json
        responses:
          201:
            body:
              application/json:
                type: bu.DeviceManagementResponseType
                example: !include examples/ex2.json   

您遇到问题的代码 在阅读完文档后,我尝试使用 operation.request().payloads().get(0).mediaType().value() 但返回 application/json 这不是我想要的,我想要 application/json 中的类型,即 bu.BlockCodeUpdatesRequestType。示例的情况也是如此,我无法阅读这些内容payloads().get(0).examples() 由于某种原因显示为空,我不知道如何访问这些内容。仅获取示例中的路径就足够了。

其他背景 rt bu 之类的变量是在 uses:

下定义的 RAML 库文件

我在 Github here 上问了同样的问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)