Nswag: System.IO.Stream generated instead of request object type, for C# client

Created on 31 Jan 2020  路  7Comments  路  Source: RicoSuter/NSwag

Change in behaviour noticed between NSwagStudio 13.2.0 and 13.2.2.

With a swagger 2.0 yaml spec with this path definition:

paths:
  '/my-path':
    post:
      tags:
        - My Path
      description: >-
        My web api path
      operationId: SomeOperation
      parameters:
        - $ref: '#/parameters/AuthorizationParam'
        - $ref: '#/parameters/x-nlp-interaction-id-Param'
        - in: body
          name: MyRequestDTOBody
          description: Input data
          required: true
          schema:
            $ref: '#/definitions/MyRequestDTO'
      responses:
        '200':
          $ref: '#/responses/200Woohoo'

an IClient is generated with "System.IO.Stream" type parameter instead of MyRequestDTO. eg

c# System.Threading.Tasks.Task<WoohooResponse> SomeOperationAsync(string authorization, string x_nlp_interaction_id, System.IO.Stream myRequestDTOBody);
myRequestDTOBody should have type MyRequestDTO.

All 7 comments

Can also you post the schema of MyRequestDTO?

Hi Rico, please find attached a simple test case that demonstrates the issue. I've included the two C# clients generated from the two different versions of NSwagStudio.

TestCaseForIssue2664.zip

I also experienced this issue when attempting to generate a C# client from a swagger 2.0 JSON doc generated with Haskell and Servant for an API. It did exactly what @philmccarthy40 described. The fix was to revert to NSwag version 13.2.0.

Any updates on this one? I'm having a swagger 2.0 json spec and since I updated NSwag from 13.0.4.0 to 13.6.0.0 I am facing the same behavior...
Looks like that makes me stuck to the version 13.2.0

We changed this behavior in 13.7/13.8 (but for OAI 3) so maybe this is fixed?

I've regenerated the test case using NSwagStudio 13.8.1; visually comparing the generated C# outputs, I can confirm the issue has been fixed. Many thanks @RicoSuter 馃憤

Was this page helpful?
0 / 5 - 0 ratings