簡體   English   中英

swagger-ui 現有應用程序 - JBoss EAP 7.4

[英]swagger-ui Existing application - JBoss EAP 7.4

我正在嘗試將我們的 RESTEasy API 與 swagger-ui 集成,以允許外部模塊開發人員針對我們的界面進行測試。

當談到對現有 API 的支持時,我的知識有點模糊。 包含 REST API 的服務是一個應用程序打包到部署在 JBoss EAP 7.4 服務器上的 *.ear 文件中。

我在 undertow web-server 上部署了 swagger-ui 的 *.dist 文件夾,並且可以訪問 swagger-ui。 到目前為止,一切都很好。

My question is now: is it at all possible to have swagger detect the resource contents of the *.ear file without my having to configure the swagger.json manually, or, alternatively, package it into a *.war file and deploy it on EAP?

如果是這樣,如何進行? 我需要 swagger-codegen,檢查員 oder 會以某種方式工作嗎?

感謝您的任何指示。

Swagger 無法自動檢測到這些。 但是,如果您已經在耳中公開了swagger.json文件,那么也許您可以更改 swagger-ui 源以在啟動時查找該特定地址。 您應該將以下代碼中的url屬性更改為指向您自己的:

window.onload = function() {
  
      //<editor-fold desc="Changeable Configuration Block">
      window.ui = SwaggerUIBundle({
        "dom_id": "#swagger-ui",
        deepLinking: true,
        presets: [
          SwaggerUIBundle.presets.apis,
          SwaggerUIStandalonePreset
        ],
        plugins: [
          SwaggerUIBundle.plugins.DownloadUrl
        ],
        layout: "StandaloneLayout",
        queryConfigEnabled: true,
        validatorUrl: "https://validator.swagger.io/validator",
        url: "https://YOUR_SERVER/CONTEXT_PATH/swagger.json" // <-- CHANGE THIS URL
      })
      
      //</editor-fold>
};

此外,如果您使用的是 WildFly 的更新版本,還有一個名為microprofile-openapi-smallrye的專用子系統,您可以啟用它來自動為您生成json文件。 您可以在本教程中找到有關它的更多詳細信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM