Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for $ref in requestBody of endpoint #4747

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Eruzo
Copy link

@Eruzo Eruzo commented Jan 31, 2024

This pull request adds 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).

Changes to [src/NSwag.Core/OpenApiDocument.Serialization.cs] and [src/NSwag.Core/OpenApiComponents.cs] are probably not needed.

Fixes #4093 as well I think

@Eruzo Eruzo changed the title Allow $ref in requestBody of endpoint Add support for $ref in requestBody of endpoint Jan 31, 2024
@Eruzo Eruzo force-pushed the allow-ref-on-request-bodies branch from e51fca0 to 76c9d50 Compare January 31, 2024 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request body is mapped to object instead of DTO type
1 participant