Skip to content

Refactor ClientGenerator to Enhance Type Handling and Naming Conventions#53

Merged
shibayan merged 1 commit into
masterfrom
abstraction
Apr 18, 2026
Merged

Refactor ClientGenerator to Enhance Type Handling and Naming Conventions#53
shibayan merged 1 commit into
masterfrom
abstraction

Conversation

@shibayan

Copy link
Copy Markdown
Owner
  • Removed the _generatedEnumTypeNames field to streamline enum type management.
  • Introduced TypeShape enum to categorize schema types more effectively.
  • Created TypeUsage class to encapsulate type information, including nullable handling.
  • Updated ParameterInfo, SchemaPropertyDefinition, and RequestBodyInfo classes to utilize TypeUsage for type definitions.
  • Enhanced naming conventions for generated classes and methods to avoid collisions by implementing unique name allocation strategies.
  • Improved response handling to correctly manage nullable types and binary responses.
  • Added tests to ensure unique naming for tags, methods, parameters, and schemas that normalize to the same identifier.
  • Refined schema resolution logic to support nullable properties and enhance overall type safety.

- Removed the _generatedEnumTypeNames field to streamline enum type management.
- Introduced TypeShape enum to categorize schema types more effectively.
- Created TypeUsage class to encapsulate type information, including nullable handling.
- Updated ParameterInfo, SchemaPropertyDefinition, and RequestBodyInfo classes to utilize TypeUsage for type definitions.
- Enhanced naming conventions for generated classes and methods to avoid collisions by implementing unique name allocation strategies.
- Improved response handling to correctly manage nullable types and binary responses.
- Added tests to ensure unique naming for tags, methods, parameters, and schemas that normalize to the same identifier.
- Refined schema resolution logic to support nullable properties and enhance overall type safety.
@shibayan shibayan requested a review from Copilot April 18, 2026 07:19
@shibayan shibayan self-assigned this Apr 18, 2026
@shibayan shibayan added the enhancement New feature or request label Apr 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors the OpenAPI client generator to improve type/nullability handling and to enforce collision-resistant naming across schemas, tags, operations, and parameters.

Changes:

  • Introduces TypeUsage/TypeShape to centrally model C# type naming, shape classification, and nullability rules.
  • Adds deterministic unique-name allocation for schemas, schema properties, tag clients, operation methods, parameters, and request body parameters.
  • Improves response handling for nullable referenced schemas and referenced binary payload schemas; adds regression tests for these behaviors.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/OpenApiWeaver.Tests/ClientGeneratorTests.Schemas.cs Adds tests for schema/type and schema-property name collisions, plus required nullable referenced properties.
tests/OpenApiWeaver.Tests/ClientGeneratorTests.Operations.cs Adds tests for tag/method/parameter collision handling and referenced nullable/binary response behaviors.
src/OpenApiWeaver/ClientGenerator.Transformer.Schemas.cs Implements schema/type-name allocation, unique property naming, TypeUsage-based type resolution, and nullable reference resolution.
src/OpenApiWeaver/ClientGenerator.Transformer.RequestBodies.cs Uses TypeUsage and allocates unique request-body and form property names to avoid collisions.
src/OpenApiWeaver/ClientGenerator.Transformer.Operations.cs Allocates unique tag client names, method names, and parameter names; refactors response typing around TypeUsage.
src/OpenApiWeaver/ClientGenerator.Transformer.Naming.cs Adds identifier normalization helpers and a shared unique-name allocator.
src/OpenApiWeaver/ClientGenerator.Model.cs Introduces TypeShape and TypeUsage; updates model types to carry structured type/nullability info and renamed “wire” fields.
src/OpenApiWeaver/ClientGenerator.Emitter.cs Removes enum-type tracking state that’s no longer needed with TypeUsage.
src/OpenApiWeaver/ClientGenerator.Emitter.Schemas.cs Emits schema properties and nested schemas using TypeUsage and updated model field names.
src/OpenApiWeaver/ClientGenerator.Emitter.RequestBodies.cs Emits request body assignments and form fields using allocated request-body parameter names and updated wire fields.
src/OpenApiWeaver/ClientGenerator.Emitter.Operations.cs Emits operation signatures/bodies using TypeUsage, unique parameter/body names, and updated response nullability handling.
src/OpenApiWeaver/ClientGenerator.Emitter.Naming.cs Removes old “requires non-null response” logic superseded by TypeUsage.RequiresNonNullJsonResponse.

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

@shibayan shibayan merged commit d1c39cf into master Apr 18, 2026
8 checks passed
@shibayan shibayan deleted the abstraction branch April 18, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants