Skip to content

[repo-assist] test: cover request body content types and OperationCompiler options (+18 tests, 396→414)#432

Merged
sergey-tihon merged 5 commits into
masterfrom
repo-assist/test-request-body-types-and-compiler-options-302f8d74497e883b
May 13, 2026
Merged

[repo-assist] test: cover request body content types and OperationCompiler options (+18 tests, 396→414)#432
sergey-tihon merged 5 commits into
masterfrom
repo-assist/test-request-body-types-and-compiler-options-302f8d74497e883b

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Adds 18 new unit tests covering previously untested OperationCompiler behaviours, and fixes a misleading comment in the same file.

New tests — request body content types

The OperationCompiler already handles five distinct content types for request bodies, but none of them had unit-test coverage at the compilation level. Each new group below verifies the generated method exists, the parameter is named correctly (matching PayloadType.ToString()), and CancellationToken is always the last parameter:

Content-Type Generated parameter name
application/x-www-form-urlencoded formUrlEncoded
multipart/form-data formData
application/octet-stream octetStream
requestBody with empty content: {} (NoMediaType) noData

The NoMediaType case resolves the // todo: we need to test it comment in OperationCompiler.fs.

New tests — compiler option flags

ignoreControllerPrefix and ignoreOperationId are significant OpenApiClientProvider static parameters but had no unit-level test coverage:

  • ignoreControllerPrefix=false verifies that operations with Controller_Method operation IDs are split into separate Pet_Client / User_Client types, each containing only their controller's methods.
  • ignoreControllerPrefix=true verifies that all operations land in a single Client type.
  • ignoreOperationId=true verifies that method names are derived from the HTTP verb + path segments rather than the operationId field, and that the original operationId-based names are absent.

New test helper

compileV3SchemaWithOptions added to Schema.TestHelpers.fs lets future tests configure ignoreControllerPrefix and ignoreOperationId independently without duplicating the schema-parsing boilerplate.

Comment fix (Task 5 — coding improvement)

Replaced the misleading // Assume that server treat it as applicationJson comment in the NoMediaType branch of OperationCompiler.fs with an accurate description of what the code actually does.

Test Status

SwaggerProvider.Tests  Total: 414, Errors: 0, Failed: 0, Skipped: 1, Time: ~1s
                       (was 396 before this PR — net +18 tests)

All tests pass. Format check clean (Fantomas unchanged).

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@c7d030cd6d4607b90d9ac3ffc8b24aff4f251632

…(+18 tests, 396→414)

Add unit tests for previously untested OperationCompiler behaviours:

- application/x-www-form-urlencoded request body → 'formUrlEncoded' parameter
- multipart/form-data request body → 'formData' parameter
- application/octet-stream request body → 'octetStream' parameter
- requestBody with empty content (NoMediaType) → 'noData' parameter
- ignoreControllerPrefix=false: operations split into per-controller client types
- ignoreOperationId=true: method names derived from path/HTTP method

Also add compileV3SchemaWithOptions helper to Schema.TestHelpers.fs so future
tests can configure ignoreControllerPrefix and ignoreOperationId independently.

Fix a misleading comment in OperationCompiler.fs (NoMediaType branch said
'Assume applicationJson' but the code uses NoData payload type).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sergey-tihon sergey-tihon marked this pull request as ready for review May 12, 2026 20:30
Copilot AI review requested due to automatic review settings May 12, 2026 20:30
Copy link
Copy Markdown
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

Adds missing unit-level coverage around OperationCompiler request-body content-type handling and provider option flags, plus a small comment update in OperationCompiler.fs to clarify the NoMediaType branch.

Changes:

  • Add compilation-level tests for request-body content types (x-www-form-urlencoded, multipart/form-data, octet-stream, and empty content: {}).
  • Add tests for ignoreControllerPrefix and ignoreOperationId behaviors in generated client/type/method names.
  • Introduce a new schema test helper to compile with explicit OperationCompiler option flags.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/SwaggerProvider.Tests/Schema.TestHelpers.fs Adds compileV3SchemaWithOptions helper to compile schemas with OperationCompiler option flags.
tests/SwaggerProvider.Tests/Schema.OperationCompilationTests.fs Adds new unit tests covering request-body content types and OperationCompiler option behaviors.
src/SwaggerProvider.DesignTime/OperationCompiler.fs Updates the NoMediaType branch comment describing request-body handling with empty content.

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

Comment thread src/SwaggerProvider.DesignTime/OperationCompiler.fs Outdated
Comment thread tests/SwaggerProvider.Tests/Schema.TestHelpers.fs Outdated
@sergey-tihon
Copy link
Copy Markdown
Member

@copilot review inline comments and address if applicable

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

@copilot review inline comments and address if applicable

Addressed the applicable inline review items in commit 670f1bd: updated the NoMediaType comment in OperationCompiler.fs to match actual runtime behavior (placeholder parameter, no body emitted), and refactored Schema.TestHelpers.fs to reuse shared v3 schema parsing logic in compileV3SchemaWithOptions.

Copy link
Copy Markdown
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

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

Comment thread tests/SwaggerProvider.Tests/Schema.TestHelpers.fs Outdated
@sergey-tihon sergey-tihon merged commit d53b17f into master May 13, 2026
2 checks passed
@sergey-tihon sergey-tihon deleted the repo-assist/test-request-body-types-and-compiler-options-302f8d74497e883b branch May 13, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants