0

我在 node.js 中使用 swagger。我想使用 x-ms-dynamic-values 动态地将值返回给我的参数。

基本上,第一个参数将有一个 URL,然后 node.js 端点将向该 URL 发出 get 请求并返回让我们说问题,每个 URL 可以有不同数量的问题,问题也可以不同。获取请求可以获得页面上包含大量问题的 json 响应。在我的下一个参数中,我希望能够根据该响应选择一个问题。

这是 x-ms-dynamic-values 发挥作用的地方,但我几乎 100% 确定没有与 node.js 一起使用的示例,我唯一能找到的是 c# 示例,我将在下面链接这个。

所以基本上我的问题是,任何人都可以提供我可以使用的 node.js 的一个小例子吗?

招摇代码示例:

"paths":{
      "/api/contacts/{name}":{
         "get":{
            "tags":[
               "DynamicSchemas"
            ],
            "summary":"Get Contact Info",
            "description":"Gets contact info of the specified type",
            "operationId":"GetContactInfo",
            "consumes":[

            ],
            "produces":[
               "application/json",
               "text/json",
               "application/xml",
               "text/xml"
            ],
            "parameters":[
               {
                  "name":"name",
                  "in":"path",
                  "required":true,
                  "type":"string",
                  "x-ms-summary":"Contact Name"
               },
               {
                  "name":"contactType",
                  "in":"query",
                  "description":"Try either \"Phone\" or \"Email\"",
                  "required":true,
                  "type":"string",
                  "x-ms-summary":"Contact Type"
               }
            ],
            "responses":{
               "200":{
                  "description":"OK",
                  "schema":{
                     "$ref":"#/definitions/ContactInfo"
                  }
               },
               "400":{
                  "description":"Invalid type specified"
               },
               "default":{
                  "description":"OK",
                  "schema":{
                     "$ref":"#/definitions/ContactInfo"
                  }
               }
            }

Api 示例:https ://github.com/nihaue/TRex/tree/master/Source

4

0 回答 0