visual studio – Generating C# Rest API Client from swagger.json


I am attempting to create a Rest API Client from the Swagger json file generated by Ambari. Unfortunately the json uses # in item names:

  "get": {
    "tags": [ "Actions" ],
    "summary": "Get all action definitions",
    "description": "",
    "operationId": "ActionService#getActionDefinitions",       <<<<<
    "produces": [ "text/plain" ],

I have tried AutoRest, Nswag, Swagger and Open API Rest API Client Generators.
Nswag is the only one that does not crash and burn.
However it’s output is unusable because the ‘#’ characters end up in the c# names.

I end up with lines like…unusable:

System.Threading.Tasks.Task<System.Collections.Generic.ICollection<ActionResponseSwagger>> ActionService#getActionDefinitionsAsync(string fields, string sortBy, int? page_size, string from, string to);

Is there a work around to this issue ?

Leave a Reply

Your email address will not be published. Required fields are marked *