Azure Api 管理可以公开 OpenAPI 文档吗?
Can Azure Api Management expose OpenAPI documentation?
我们通过 Api 管理公开了一些 Azure 功能? Api 管理可以自动公开一个 /swagger 端点,就像 Swashbuckle 包对 Asp.Net.
中的 api 所做的一样
Azure API 管理无法自动生成 swagger 页面。 AzureAPI管理只能provide you the API definition file. Then you can use other tools (such as Swagger UI)用定义文件生成你需要的页面。
此外,Azure API 管理层为您提供了 UI(https://youapimanagementname.portal.azure-api.net) 来告诉您如何使用所有 API。
您可以通过 API 本身公开您的 openapi 文档。
可以在
上请求 API 的文档
只需在您的 API 上创建一个额外的操作(例如 openapi.yaml),通过自定义策略调用上面的 url 并 return 结果。您可以使用以下政策
<policies>
<inbound>
<base />
<send-request mode="new" response-variable-name="result" timeout="300" ignore-error="false">
<set-url>@("https://management.azure.com/subscriptions/{{azure-subscriptionid}}/resourceGroups/{{azure-resourcegroup}}/providers/Microsoft.ApiManagement/service/" + context.Deployment.ServiceName + "/apis/" + context.Api.Id + "?export=true&format=openapi&api-version=2021-01-01-preview")</set-url>
<set-method>GET</set-method>
<authentication-managed-identity resource="https://management.azure.com/" />
</send-request>
<return-response>
<set-status code="200" reason="OK" />
<set-header name="Content-Type" exists-action="override">
<value>application/yaml</value>
</set-header>
<set-body>@((string)(((IResponse)context.Variables["result"]).Body.As<JObject>()["value"]))</set-body>
</return-response>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
可以在 https://www.devprotocol.com/2021/07/20/expose-openapi-documentation-on-azure-api-management.html
上找到更多信息
我们通过 Api 管理公开了一些 Azure 功能? Api 管理可以自动公开一个 /swagger 端点,就像 Swashbuckle 包对 Asp.Net.
中的 api 所做的一样Azure API 管理无法自动生成 swagger 页面。 AzureAPI管理只能provide you the API definition file. Then you can use other tools (such as Swagger UI)用定义文件生成你需要的页面。
此外,Azure API 管理层为您提供了 UI(https://youapimanagementname.portal.azure-api.net) 来告诉您如何使用所有 API。
您可以通过 API 本身公开您的 openapi 文档。 可以在
上请求 API 的文档只需在您的 API 上创建一个额外的操作(例如 openapi.yaml),通过自定义策略调用上面的 url 并 return 结果。您可以使用以下政策
<policies>
<inbound>
<base />
<send-request mode="new" response-variable-name="result" timeout="300" ignore-error="false">
<set-url>@("https://management.azure.com/subscriptions/{{azure-subscriptionid}}/resourceGroups/{{azure-resourcegroup}}/providers/Microsoft.ApiManagement/service/" + context.Deployment.ServiceName + "/apis/" + context.Api.Id + "?export=true&format=openapi&api-version=2021-01-01-preview")</set-url>
<set-method>GET</set-method>
<authentication-managed-identity resource="https://management.azure.com/" />
</send-request>
<return-response>
<set-status code="200" reason="OK" />
<set-header name="Content-Type" exists-action="override">
<value>application/yaml</value>
</set-header>
<set-body>@((string)(((IResponse)context.Variables["result"]).Body.As<JObject>()["value"]))</set-body>
</return-response>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
可以在 https://www.devprotocol.com/2021/07/20/expose-openapi-documentation-on-azure-api-management.html
上找到更多信息