unchase/Unchase.OpenAPI.Connectedservice

Updating / Regenerating a service client causes error in Visual Studio

Closed this issue · 9 comments

Describe the bug

If you try to update a previously added connected service (OpenAPI C# client) an error happens and Visual Studio shows a message box. The connected service is also not updated.

The error message is:

Connected Services

The Connected Services component 'Unchase OpenAPI 
(Swagger) Connected Service' failed: (HRESULT:0x80131500) 
Error setting value to 'PathPrefix' on 
'Microsoft.OpenApi.OData.OpenApiConvertSettings'.

Assemblies affected

v1.5.13

Steps to reproduce

  1. Open a project with an existing OpenAPI C# client
  2. Click on 'Connected Services'
  3. Right-click on the 'client folder'
  4. Click 'Update Unchase OpenAPI (Swagger) Connected Service...'
  5. Error happens - Message box is shown

Expected result

The C# client is updated to the current state as specified by the API URI

Actual result

An error message is shown. Otherwise nothing happens

Additional detail

The likely cause is the recent dependency update of Microsoft.OpenApi.OData to v1.0.6
As v1.0.6 contains the following commit Add Path provider and path prefix provider into setting

Now PathPrefix being null or the empty string is blocked in OpenApiConvertSettings.cs

The ConnectedService.json generated by this extension - which is loaded when you want to update the c# client - contains "PathPrefix": null, which causes the described error.

If you manually change the content to e.g. "PathPrefix": "/", you can update the c# client once but afterwards PathPrefix is again set to null

Hello @unchase , with latest version 1.5.14.0 => bug already exists. (with PathPrefix null or "")

image

Hi, @cmonzon44
I checked the issue again with 1.5.14. There is no errors.
Are you sure you have updated the connected service to the latest version?
Can you show your ConnectedService.json file?

@unchase

I updated to v1.5.14 of the extension and retested.
The described problem persists for me.

I additionally noticed a Warning:Failed loading the Unchase.OpenAPI.ConnectedService_Settings.xml user settings warning in the VS General Output.

It seems to also fail loading the .xml from the AppData\Roaming... Folder

I attached my sanitized ConnectedService.json

ConnectedService.json.txt

Hello, the problem exists on our side too.

The last working version is:
https://github.com/unchase/Unchase.OpenAPI.Connectedservice/releases/tag/v1.5.12

@patest-dev @cmonzon44 @wirthandras
Fixed in v1.5.15.
Check it, please.
Need to regenerate (not update) the client code.

@unchase
I can confirm that with v.1.5.15 the bug is fixed for me.
Thanks you very much for the quick handling of this bug.
Your response time and willingness to fix + release new versions is superb.


  • Deleting + regenerating the client code works and now "Update .." works again.
  • Possible work around for those that don't want to delete + regenerate the client (e.g. if you specified many custom options when first generating the client)
    -- open the ConnectedService.json file
    -- change "PathPrefix": null to `"PathPrefix": "OData"
    -- save
    -- Now updating the client code via right-click should work again

@patest-dev Thanks for feedback.

@unchase
I can confirm the problem fixed, but manual workaround required in each of our existing connectedservice.json files as following: "PathPrefix":"" need to change to "PathPrefix":"OData"

@unchase
I can confirm the problem fixed, but manual workaround required in each of our existing connectedservice.json files as following: "PathPrefix":"" need to change to "PathPrefix":"OData"

Thank you!