Skip to content

Conversation

@Numpsy
Copy link
Contributor

@Numpsy Numpsy commented Dec 15, 2025

Just seeing if this acts as a minimal repro/text for #275

@sergey-tihon sergey-tihon marked this pull request as ready for review December 22, 2025 11:28
Copilot AI review requested due to automatic review settings December 22, 2025 11:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive support for consuming and producing text/plain content type, serving as a minimal reproduction test for issue #275. The changes implement a complete end-to-end text/plain media type handling pipeline.

Key changes:

  • Added text/plain input formatter for reading plain text request bodies
  • Extended the SwaggerProvider runtime and design-time compilers to handle text/plain payload types
  • Added a test controller and corresponding test to verify the functionality

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Swashbuckle.WebApi.Server/Startup.fs Registers the new TextPlainInputFormatter in the MVC pipeline
tests/Swashbuckle.WebApi.Server/Controllers/ReturnTextControllers.fs Adds ConsumesTextController for handling text/plain POST requests and TextPlainInputFormatter implementation
tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.ReturnTextControllers.Tests.fs Adds test case for sending and receiving text/plain content
src/SwaggerProvider.Runtime/RuntimeHelpers.fs Adds TextPlain media type constant and toTextContent helper function
src/SwaggerProvider.DesignTime/v3/OperationCompiler.fs Extends PayloadType enum and operation compiler to handle TextPlain payload type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


override _.ReadRequestBodyAsync(context, encoding) =
task {
use reader = new StreamReader(context.HttpContext.Request.Body, encoding)
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The StreamReader should be constructed with leaveOpen: true to prevent it from disposing the underlying Request.Body stream. When the StreamReader is disposed by the use binding, it will by default also dispose the Request.Body stream, which is owned by ASP.NET Core and should not be disposed by the formatter.

Suggested change
use reader = new StreamReader(context.HttpContext.Request.Body, encoding)
use reader = new StreamReader(context.HttpContext.Request.Body, encoding, true, 1024, true)

Copilot uses AI. Check for mistakes.
@sergey-tihon sergey-tihon merged commit 031d910 into fsprojects:master Dec 22, 2025
7 checks passed
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.

2 participants