Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors several internal ClientGenerator transformer/emitter helpers to reduce duplication and simplify logic in the OpenAPI → client-model → emitted-source pipeline.
Changes:
- Consolidates repeated escaping/identifier-normalization logic into reusable helper methods.
- Refactors request body value-kind classification and content-type mapping to improve clarity and error reporting.
- Centralizes response media-type prioritization logic to reduce repetition.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/OpenApiWeaver/ClientGenerator.cs | Removes redundant OpenAPI-document filtering inside TryCreateInput (filtering already happens in the incremental pipeline). |
| src/OpenApiWeaver/ClientGenerator.Transformer.Schemas.cs | Removes unused helpers and slightly restructures nullability logic for readability. |
| src/OpenApiWeaver/ClientGenerator.Transformer.RequestBodies.cs | Refactors request-body kind/value-kind classification and replaces hardcoded content-type mapping with a static table. |
| src/OpenApiWeaver/ClientGenerator.Transformer.Operations.cs | Centralizes media-type priority logic used for selecting preferred response/error content. |
| src/OpenApiWeaver/ClientGenerator.Transformer.Naming.cs | Consolidates Pascal/camel identifier normalization into a shared helper. |
| src/OpenApiWeaver/ClientGenerator.Emitter.cs | Inlines security scheme initialization in the constructor emitter. |
| src/OpenApiWeaver/ClientGenerator.Emitter.Naming.cs | Refactors string literal escaping to reuse the shared escape helper. |
| src/OpenApiWeaver/ClientGenerator.Emitter.DocComments.cs | Refactors XML escaping via a lookup helper and slightly adjusts doc-line splitting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and simplifies several internal methods across the codebase, focusing on improving maintainability, reducing code duplication, and clarifying logic for request body handling, escaping, and identifier normalization. The changes also introduce helper methods and reorganize priority logic for media type selection.
Refactoring and Code Simplification:
EscapeByLookupmethod, and updatedEscapeXmlDocumentationText,EscapeXmlDocumentationAttribute, andEscapeStringLiteralto use it, reducing code duplication and improving maintainability. [1] [2] [3] [4]EmitSecuritySchemeInitializationhelper method with inline code for simplicity.Request Body and Schema Handling Improvements:
ClassifyValueKindand related helpers, improving clarity and error reporting for unsupported schema types and array items. [1] [2] [3]Media Type Selection and Prioritization:
GetContentPrioritymethod with predicate arrays, improving flexibility and reducing repetition in media type selection.SelectPreferredContentmethod.Identifier Normalization:
NormalizeIdentifier, reducing duplication and clarifying intent.Minor Cleanups:
ResolveTypeNamemethod.