Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.37k stars 4.78k forks source link

Microsoft.Azure.Management.ApiManagement export an openApi specification #17584

Closed ghost closed 2 years ago

ghost commented 3 years ago

Question How to well export an API details (OpenApi specification) by using Microsoft.Azure.Management.ApiManagement with IApiExportOperations?

Environment:

Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.101\

Host (useful for support): Version: 5.0.1 Commit: b02e13abab

.NET SDKs installed: 2.2.207 [C:\Program Files\dotnet\sdk] 3.1.404 [C:\Program Files\dotnet\sdk] 5.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

 - IDE and version : **Visual Studio Entreprise 2019 v 16.8.3**

 ## The situation

 I'm using `Microsoft.Azure.Management.ApiManagement` to do a lot of actions on my Azure Api Management instance

 I want to retrieve the `OpenApi specification` of a target API, to do that I'm trying to use this [method ](https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.management.apimanagement.apiexportoperationsextensions.getasync?view=azure-dotnet#Microsoft_Azure_Management_ApiManagement_ApiExportOperationsExtensions_GetAsync_Microsoft_Azure_Management_ApiManagement_IApiExportOperations_System_String_System_String_System_String_System_String_System_Threading_CancellationToken_)`Task<ApiExportResult> GetAsync(...)` from `IApiExportOperations ` Interface. I'm using this method to read from its response the `OpenApi specification json data value`.

 Here is my code:
 ```c#
 public async Task<ApiExportResult> GetApiDetails(ApimGetApiDto apimGetApiDto)
{
        return await _apiManagementClient.ApiExport.GetAsync(apimGetApiDto.ResourceGroupName, apimGetApiDto.ServiceName,
              apimGetApiDto.ApiId, "Swagger"); //according to the documentation format can be 'Swagger', 'Wsdl', 'Wadl', 'Openapi', 'OpenapiJson'
}

Then I'm calling this method from a controller.

My problem: Whatever the format I'm using, I always receive from my controller an ApiExportResult object with nullable value property.

 {
    "id": "/subscriptions/.../apis/myApiId",
    "exportResultFormat": null,
    "value": null
}

I tried to do the same thing manually by using this endpoint "Api Export" from REST API Management and I got what I'm loking for (I got a link that redirect me to the target OpenApi specification). So I'm sure after this manual test that I can do the same thing using Microsoft.Azure.Management.ApiManagement with the GetAsync(), but until now I can not do it as expected (I miss something).

Can you please challenge me with your ideas?

thank you! 😊

jsquire commented 3 years ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @miaojiang.

Issue Details
**Question** How to well export an API details (OpenApi specification) by using `Microsoft.Azure.Management.ApiManagement` with `IApiExportOperations`? **Environment:** - I'm using `Microsoft.Azure.Management.ApiManagement 6.0.0-preview` - Hosting platform or OS and .NET runtime version: ```powershell dotnet --info .NET SDK (reflecting any global.json): Version: 5.0.101 Commit: d05174dc5a Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.101\ Host (useful for support): Version: 5.0.1 Commit: b02e13abab .NET SDKs installed: 2.2.207 [C:\Program Files\dotnet\sdk] 3.1.404 [C:\Program Files\dotnet\sdk] 5.0.101 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] ``` - IDE and version : **Visual Studio Entreprise 2019 v 16.8.3** ## The situation I'm using `Microsoft.Azure.Management.ApiManagement` to do a lot of actions on my Azure Api Management instance I want to retrieve the `OpenApi specification` of a target API, to do that I'm trying to use this [method ](https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.management.apimanagement.apiexportoperationsextensions.getasync?view=azure-dotnet#Microsoft_Azure_Management_ApiManagement_ApiExportOperationsExtensions_GetAsync_Microsoft_Azure_Management_ApiManagement_IApiExportOperations_System_String_System_String_System_String_System_String_System_Threading_CancellationToken_)`Task GetAsync(...)` from `IApiExportOperations ` Interface. I'm using this method to read from its response the `OpenApi specification json data value`. Here is my code: ```c# public async Task GetApiDetails(ApimGetApiDto apimGetApiDto) { return await _apiManagementClient.ApiExport.GetAsync(apimGetApiDto.ResourceGroupName, apimGetApiDto.ServiceName, apimGetApiDto.ApiId, "Swagger"); //according to the documentation format can be 'Swagger', 'Wsdl', 'Wadl', 'Openapi', 'OpenapiJson' } ``` Then I'm calling this method from a `controller`. **My problem**: Whatever the format I'm using, I always receive from my controller an `ApiExportResult` object with nullable `value` property. ```json { "id": "/subscriptions/.../apis/myApiId", "exportResultFormat": null, "value": null } ``` I tried to do the same thing manually by using this [endpoint "Api Export" ](https://docs.microsoft.com/en-us/rest/api/apimanagement/2019-12-01/apiexport/get) from REST API Management and I got what I'm loking for (_I got a link that redirect me to the target OpenApi specification_). So I'm sure after this manual test that I can do the same thing using `Microsoft.Azure.Management.ApiManagement` with the `GetAsync()`, but until now I can not do it as expected (I miss something). Can you please challenge me with your ideas? thank you! 😊
Author: TarekMansour
Assignees: -
Labels: `API Management`, `Mgmt`, `Service Attention`, `customer-reported`, `needs-team-attention`, `question`
Milestone: -
ghost commented 3 years ago

Hi @TarekMansour. Thank you, for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

ghost commented 3 years ago

Hi @TarekMansour. There was a mistake and this issue was unintentionally flagged as a stale pull request. The label has been removed and the issue will remain active; no action is needed on your part. Apologies for the inconvenience.

SaurabhSharma-MSFT commented 2 years ago

@TarekMansour Apologies for the delayed response. I see that this issue is opened long time ago and no further activity had taken place. So wanted to check if you are still looking for assistance on this query? Please let us know .

ghost commented 2 years ago

Hi, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!