小编zag*_*010的帖子

带有多个网址的Swagger UI

我在swagger ui文档中看到你可以提供一个urls参数,它是:

Topbar插件使用的一组API定义对象({url:"",name:""}).使用和启用Topbar插件时,将不会解析url参数.名称和URL在此数组中的所有项目中必须是唯一的,因为它们用作标识符.

我希望这会给我一个选择器,我可以从中选择我要处理的yaml文件.不幸的是,它似乎没有做任何事情.

这是我的代码:

window.onload = function() {
  // Build a system
  const ui = SwaggerUIBundle({
    urls: [
    {url:"http://test.dev/documentation/microservices/microservices.yaml",name:"All Microservices"},
    {url:"http://test.dev/documentation/microservices/plans.yaml",name:"Plans"},
    ],
    dom_id: '#swagger-ui',
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],
    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl
    ],
    layout: "StandaloneLayout"
  })

  window.ui = ui
}
Run Code Online (Sandbox Code Playgroud)

我还想将primaryName设置为All Microservices.

关于我哪里出错的任何想法?

swagger-ui

9
推荐指数
1
解决办法
7177
查看次数

使用 Lodash 修改数组中的键

我正在尝试用 lodash 修改对象数组,但有点挣扎。我想获取下面的数组并更改对象中的键。

这是我的源数组:

[
    {
        "id": "AD",
        "name": "Andorra",
        "currency": "EUR",
        "timezone": "Europe/Andorra",
        "links": [
            {
                "rel": "self",
                "href": "http://localhost:8000/api/countries/AD"
            },
            {
                "rel": "country.currency",
                "href": "http://localhost:8000/api/currencies/EUR"
            }
        ]
    },
    {
        "id": "AE",
        "name": "United Arab Emirates",
        "currency": "AED",
        "timezone": "Asia/Dubai",
        "links": [
            {
                "rel": "self",
                "href": "http://localhost:8000/api/countries/AE"
            },
            {
                "rel": "country.currency",
                "href": "http://localhost:8000/api/currencies/AED"
            }
        ]
    },
    ...
    ]
Run Code Online (Sandbox Code Playgroud)

我希望这会导致:

[
    {
        "value": "AD",
        "title": "Andorra",
        "currency": "EUR",
        "timezone": "Europe/Andorra",
        "links": [
            {
                "rel": "self",
                "href": "http://localhost:8000/api/countries/AD"
            },
            {
                "rel": …
Run Code Online (Sandbox Code Playgroud)

javascript lodash

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

javascript ×1

lodash ×1

swagger-ui ×1