Skip to content

Simplify code generation and unify JSON media type detection - #125

Merged
shibayan merged 1 commit into
masterfrom
codex/simplify-generation
Sep 30, 2026
Merged

shibayan merged 1 commit into
masterfrom
codex/simplify-generation

Conversation

@shibayan

Copy link
Copy Markdown
Owner

Summary

Reduce duplicated generation logic by sharing optional parameter emission and simple schema type mappings, and replace predicate-array content priorities with direct conditions.

Unify JSON media type detection for requests, responses, and generated error handling. Only application/json and application/*+json are recognized, ignoring case and media type parameters. For example, text/plain; profile=json and application/jsonp now use text handling instead of JSON deserialization. Other generated behavior is preserved.

Related issue

None.

Type of change

  • Bug fix
  • Documentation
  • Refactoring or maintenance

Validation

  • dotnet build OpenApiWeaver.slnx --no-restore (0 warnings, 0 errors)
  • dotnet format OpenApiWeaver.slnx --verify-no-changes --verbosity detailed --no-restore (passed; reported a workspace loading warning)
  • dotnet test OpenApiWeaver.slnx --no-restore (159 passed)

Impact checklist

  • Added regression coverage for response generation and generated runtime JSON detection, including media type parameters and misleading names
  • Updated README.md for the JSON media type behavior
  • Called out notable generated output changes in the summary

Notes for reviewers

No diagnostics were introduced or changed. JSON media type recognition is the intentional behavior change; the remaining changes simplify existing implementation paths.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 04:31

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.

Copilot review overview

🟢 Approval recommended

The refactors preserve existing behavior while the intentional media-type change is consistent, documented, and regression-tested.

Review effort: Balanced
Findings: None

What changed in this PR

Simplifies generation internals while consistently recognizing only valid JSON application media types.

Changes:

  • Centralizes JSON media-type detection across requests, responses, and generated error handling.
  • Deduplicates parameter emission and schema type mapping logic.
  • Adds regression tests and documents JSON detection behavior.
File Description
README.md Documents recognized JSON media types.
tests/​OpenApiWeaver.Tests/​ClientGeneratorTests.Operations.cs Adds JSON detection regression coverage.
src/​OpenApiWeaver/​OpenApi/​SchemaTypeResolver.cs Consolidates simple schema mappings.
src/​OpenApiWeaver/​Generator/​Transforming/​ClientGenerator.Transformer.Responses.cs Applies strict JSON response detection.
src/​OpenApiWeaver/​Generator/​Transforming/​ClientGenerator.Transformer.RequestBodies.cs Removes duplicated media-type helpers.
src/​OpenApiWeaver/​Generator/​Transforming/​ClientGenerator.Transformer.Content.cs Centralizes media-type matching and priorities.
src/​OpenApiWeaver/​Generator/​SupportTypes/​ClientGenerator.SupportTypesEmitter.Response.cs Generates strict runtime JSON detection.
src/​OpenApiWeaver/​CodeGeneration/​OperationEmitter.Parameters.cs Adds shared optional-parameter emission.
src/​OpenApiWeaver/​CodeGeneration/​OperationEmitter.cs Uses shared parameter emission paths.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@shibayan
shibayan merged commit 3b853d9 into master Sep 30, 2026
5 checks passed
@shibayan
shibayan deleted the codex/simplify-generation branch September 30, 2026 04:53
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