2015-04-20 50 views
2

我用測試控制器創建了一個簡單的api,並將其發佈爲Azure Api應用程序。我啓用了公開(匿名)訪問,swagger ui在瀏覽器中運行良好,並且swagger驗證正確,並且我添加了邏輯應用程序需要的默認響應設置。爲什麼我的API應用程序的swagger對我的Azure應用程序服務邏輯應用程序不可用?

但是,當我嘗試將API應用程序添加到我的邏輯應用程序時,我遇到了一個錯誤:「錯誤獲取swagger api定義」。

如果我嘗試瀏覽門戶中的API定義,我會遇到另一個錯誤:「無法獲取API定義,它可能需要API應用程序的額外配置或身份驗證。

如果我嘗試從門戶鏈接下載swagger數據,則此操作將失敗,並顯示Http 400: Bad Request

我在這裏錯過了什麼,以及如何獲得這個簡單的Api應用程序在門戶中工作?

公共URI:https://microsoft-apiappf6c70a179b1b408c99e3f2536467ff39.azurewebsites.net

揚鞭UI:https://microsoft-apiappf6c70a179b1b408c99e3f2536467ff39.azurewebsites.net/swagger/ui/index

原揚鞭:

{"swagger":"2.0","info":{"version":"v1","title":"PE.Services.Idml"},"host":"microsoft-apiappf6c70a179b1b408c99e3f2536467ff39.azurewebsites.net:443","schemes":["https"],"paths":{"/api/ToEpl":{"get":{"tags":["ToEpl"],"operationId":"ToEpl_Get","consumes":[],"produces":["application/json","text/json","application/xml","text/xml"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}},"default":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}}},"deprecated":false},"post":{"tags":["ToEpl"],"operationId":"ToEpl_Post","consumes":["application/json","text/json","application/xml","text/xml","application/x-www-form-urlencoded"],"produces":["application/json","text/json","application/xml","text/xml"],"parameters":[{"name":"value","in":"body","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/Object"}},"default":{"description":"OK","schema":{"$ref":"#/definitions/Object"}}},"deprecated":false}},"/api/ToEpl/{id}":{"get":{"tags":["ToEpl"],"operationId":"ToEpl_Get","consumes":[],"produces":["application/json","text/json","application/xml","text/xml"],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"OK","schema":{"type":"string"}},"default":{"description":"OK","schema":{"type":"string"}}},"deprecated":false},"put":{"tags":["ToEpl"],"operationId":"ToEpl_Put","consumes":["application/json","text/json","application/xml","text/xml","application/x-www-form-urlencoded"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"},{"name":"value","in":"body","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"No Content"}},"deprecated":false},"delete":{"tags":["ToEpl"],"operationId":"ToEpl_Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"204":{"description":"No Content"}},"deprecated":false}},"/api/Values":{"get":{"tags":["Values"],"operationId":"Values_Get","consumes":[],"produces":["application/json","text/json","application/xml","text/xml"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}},"default":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}}},"deprecated":false},"post":{"tags":["Values"],"operationId":"Values_Post","consumes":["application/json","text/json","application/xml","text/xml","application/x-www-form-urlencoded"],"produces":[],"parameters":[{"name":"value","in":"body","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"No Content"}},"deprecated":false}},"/api/Values/{id}":{"get":{"tags":["Values"],"operationId":"Values_GetById","consumes":[],"produces":["application/json","text/json","application/xml","text/xml"],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"OK","schema":{"type":"string"}},"default":{"description":"OK","schema":{"type":"string"}}},"deprecated":false},"put":{"tags":["Values"],"operationId":"Values_Put","consumes":["application/json","text/json","application/xml","text/xml","application/x-www-form-urlencoded"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"},{"name":"value","in":"body","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"No Content"}},"deprecated":false},"delete":{"tags":["Values"],"operationId":"Values_Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"204":{"description":"No Content"}},"deprecated":false}}},"definitions":{"Object":{"type":"object","properties":{}}}} 
+0

我有同樣的問題......你有什麼想法嗎?我試圖弄清楚自己......不知道我改變了什麼讓它停止工作,我傳遞的所有信息都是POCO的。 – Scott

+0

@Scott號我們得出結論,目前Logic Apps還沒有準備好生產。我們將使用Api應用程序和傳統的WF來連接它們,並等待文檔和一些額外的工作流程功能以適應Logic應用程序。 – JcFx

回答

3

我想這是因爲你有兩個途徑與同operationId(ToEpl_Get)。

有一些緩解

  1. 由於Swashbuckle在您的API控制器導出這個從動作名稱...你可以改變你的行爲的名字之一...... e.g。 GetById而不是獲取
  2. 或者,更改操作ID的方法是轉到SwaggerConfig.cs文件添加一個自定義操作過濾器。操作過濾器擴展點將允許您訪問操作並更改ID。

非常抱歉給您帶來不便,我們將盡快讓錯誤報告更好。

相關問題