Move model JSON usage setting out of the emitter#1243
Open
MaiLinhP wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Moves the “multipart form models should also be treated as JSON models” customization from the TypeSpec emitter into the C# generator visitor layer, aligning with the plugin’s pattern of keeping OpenAI-specific generation behavior in visitors.
Changes:
- Update
ModelSerializationVisitorto setInputModelTypeUsage.Jsonon multipart-form models viaInputModelType.Update(...). - Remove the emitter-side
CodeModelmutation callback that previously OR’edUsageFlags.Jsononto multipart-form models.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| codegen/generator/src/Visitors/ModelSerializationVisitor.cs | Adds visitor-side usage update so multipart form models are treated as JSON for MRW/serialization generation. |
| codegen/emitter/src/emitter.ts | Removes emitter-time model usage mutation callback; now delegates behavior to the generator visitors. |
Comments suppressed due to low confidence (1)
codegen/emitter/src/emitter.ts:7
CodeModelis no longer referenced after removing theemitCodeModelcallback, leaving an unused import that can break TypeScript builds when unused imports are treated as errors.
import {
emitCodeModel,
CodeModel,
CSharpEmitterOptions
} from "@typespec/http-client-csharp";
Comment on lines
+16
to
+20
| // Ensure multipart form data models also get JSON usage so that MRW serialization is generated. | ||
| if (model.Usage.HasFlag(InputModelTypeUsage.MultipartFormData) && !model.Usage.HasFlag(InputModelTypeUsage.Json)) | ||
| { | ||
| model.Update(usage: model.Usage | InputModelTypeUsage.Json); | ||
| } |
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.
Addresses #1232
With the generator update to add InputModelType Update function, we can now move model JSON usage setting from the emitter to visitor. This ensures consistency of keeping all OpenAI customization in visitors.