[repo-assist] test: cover request body content types and OperationCompiler options (+18 tests, 396→414)#432
Conversation
…(+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>
There was a problem hiding this comment.
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 emptycontent: {}). - Add tests for
ignoreControllerPrefixandignoreOperationIdbehaviors in generated client/type/method names. - Introduce a new schema test helper to compile with explicit
OperationCompileroption 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.
|
@copilot review inline comments and address if applicable |
… reuse Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/66ad4236-3faf-4579-be02-1eeba653ae48 Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Addressed the applicable inline review items in commit |
Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/66ad4236-3faf-4579-be02-1eeba653ae48 Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/d184a66e-8a08-4457-9740-61348453033d Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Adds 18 new unit tests covering previously untested
OperationCompilerbehaviours, and fixes a misleading comment in the same file.New tests — request body content types
The
OperationCompileralready 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 (matchingPayloadType.ToString()), andCancellationTokenis always the last parameter:application/x-www-form-urlencodedformUrlEncodedmultipart/form-dataformDataapplication/octet-streamoctetStreamrequestBodywith emptycontent: {}(NoMediaType)noDataThe NoMediaType case resolves the
// todo: we need to test itcomment inOperationCompiler.fs.New tests — compiler option flags
ignoreControllerPrefixandignoreOperationIdare significantOpenApiClientProviderstatic parameters but had no unit-level test coverage:ignoreControllerPrefix=falseverifies that operations withController_Methodoperation IDs are split into separatePet_Client/User_Clienttypes, each containing only their controller's methods.ignoreControllerPrefix=trueverifies that all operations land in a singleClienttype.ignoreOperationId=trueverifies that method names are derived from the HTTP verb + path segments rather than theoperationIdfield, and that the originaloperationId-based names are absent.New test helper
compileV3SchemaWithOptionsadded toSchema.TestHelpers.fslets future tests configureignoreControllerPrefixandignoreOperationIdindependently without duplicating the schema-parsing boilerplate.Comment fix (Task 5 — coding improvement)
Replaced the misleading
// Assume that server treat it as applicationJsoncomment in theNoMediaTypebranch ofOperationCompiler.fswith an accurate description of what the code actually does.Test Status
All tests pass. Format check clean (Fantomas unchanged).