RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.67k stars 1.23k forks source link

Enhance support for $ref in requestBody of endpoint #4747

Open Eruzo opened 6 months ago

Eruzo commented 6 months ago

This pull request enhances support for the $ref keyword in request bodies. Given the following oas endpoint:

/end-point-uri:
    post:
      tags:
        - SomeTag
      summary: Search for something with a request body
      description: |
       Search something with a request body that is defined as a reference
      operationId: PostSearchSomething
      parameters:
        - $ref: '#/components/parameters/CorrelationId'
        - $ref: '#/components/parameters/ReferenceDate'
      requestBody:
        $ref: '#/components/requestBodies/PostSearchSomethingRequest'

The generator would generate the following function PostSearchSomethingRequestAsync(object body) with the supplied change it will generate PostSearchSomethingRequestAsync(PostSearchSomethingRequest body).

Fixes #4093 as well I think