Propagate tcgc SerializationOptions for body parameters and responses#10730
Propagate tcgc SerializationOptions for body parameters and responses#10730Copilot wants to merge 7 commits into
Conversation
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/76d0d54b-eb95-4507-9102-0f7c4559a16d Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
… + binary cases Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/8a5e333c-20c8-4af2-895c-a32bb3a580fb Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
commit: |
jorgerangel-msft
left a comment
There was a problem hiding this comment.
@copilot lets add unit tests in the generator to validate the serialization options are properly parsed
…G parsing tests Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/c2a48df5-0802-4dbb-9605-fd08229d9620 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Added
All 125 |
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/3ccc29ec-de01-44bd-bcc6-f6c6a0ff8ad8 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…mitter binary test Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/50bac166-c40e-490f-8bd0-a9a6dbaee25e Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot there are test failing in CI. We need to ensure we regenerate all the test libraries and then ensure all tests are passing |
…ams and responses Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/dceee894-7238-4bf2-944d-1c0c90f13db2 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Regenerated all 74 test |
tcgc 0.68.0 added
serializationOptionstoSdkBodyParameterandSdkHttpResponse, but the C# emitter and MTG were still inferring wire format from the content-type header. This PR plumbs that data through so MTG can consume it directly, and switches the first XML wire-format detection site to use the new metadata.Emitter (TypeScript)
serializationOptions: SerializationOptions(required) toInputBodyParameterandOperationResponse, matching the existing shape onInputModelType/InputModelProperty.fromBodyParameterandfromSdkHttpOperationResponseby copying straight from tcgc.MTG (
Microsoft.TypeSpec.Generator.Input)SerializationOptions(of typeInputSerializationOptions) toInputBodyParameterandInputOperationResponse, with constructor parameters defaulted tonullfor back-compat.InputBodyParameterConverterandInputOperationResponseConverterto read the newserializationOptionsJSON field.InputBinarySerializationOptionstype (IsFile,IsText,ContentTypes,Filename) andInputBinarySerializationOptionsConverter, plumbed throughInputSerializationOptions/InputSerializationOptionsConverterso that binary payload metadata emitted by tcgc on model types can be deserialized in MTG.Filenameis typed asInputModelProperty?, matchingInputMultipartOptions.Filename.MTG (
Microsoft.TypeSpec.Generator.ClientModel)ScmMethodProviderCollection.TryGetXmlCollectionNamesForResponsenow gates onresponse.SerializationOptions?.Xmlinstead of scanningresponse.ContentTypesforapplication/xml, consuming the propagated metadata directly.InputFactory.OperationResponsehelper with an optionalserializationOptionsparameter and updated the affected XML list response test to supply it.Tests
model-type.test.tscovering body parameterserializationOptionspropagation:application/json+stringbody — assertsbodyParam.serializationOptions.jsonis populated.Http.File(application/octet-stream) body — asserts the body's model type carriesserializationOptions.binarywith the full set of properties:isFile === true,isText === false,contentTypes === ["application/octet-stream"], andfilename.name === "filename". Also asserts that the body parameter's ownserializationOptionshas neitherjsonnorxmlset (tcgc only derivesjson/xmlfor body params from content types;binarylives on the model type).TypeSpecInputConverterTestsinMicrosoft.TypeSpec.Generator.Input.Testsvalidating JSON deserialization ofInputSerializationOptions(empty, json, xml, binary with all properties includingfilename, binary defaults, unknown property tolerance),InputBodyParameter.SerializationOptions(json, binary withfilename, absent → null), andInputOperationResponse.SerializationOptions(xml, binary withfilename, absent → null).Follow-up
One header/content-type-based wire-format site remains for a separate change:
MrwSerializationTypeDefinition.Xml.csreads theContent-Typeresponse header at runtime to branch betweenapplication/jsonandapplication/xml; converting that to consumeSerializationOptionsis the natural next step.