Support additional properties in non-legacy Modular#2981
Support additional properties in non-legacy Modular#2981MaryGao merged 33 commits intoAzure:mainfrom
Conversation
| } | ||
|
|
||
| if (type.baseModel) { | ||
| return getAdditionalPropertiesType(type.baseModel); |
There was a problem hiding this comment.
Could you help double check what the additionalProperties type is for model B? I just wonder if tcgc or compiler has already done the union here or is it something emitter should do?
model A {
...Record<string>
}
model B extends A {
...Record<bytes>
}There was a problem hiding this comment.
Back to your question compiler would take care of any union work and you could see cases https://github.com/marygao/autorest.typescript/blob/support-additional-properties/packages/typespec-ts/test/modularUnit/scenarios/models/serialization/additionalProperties.md#typespec.
But to the specific extend case I am confirming with typespec team with correct behavior: microsoft/typespec#6983.
Currently it is compiled as overriding the parent one and see test case https://github.com/Azure/autorest.typescript/blob/b511d31069383facd6e4c60d9a82e56fbf91bb5b/packages/typespec-ts/test/modularUnit/scenarios/models/serialization/additionalProperties.md#skip-should-generate-additionalproperties-bag-for-non-legacy-code-if-additional-property-is-overrode.
There was a problem hiding this comment.
Our generation is correct but typespec would report errors for non-compile code, let's wait their fix and turn on this case.
| default: paramMessage`Please note the header ${"type"} is not serializable.` | ||
| } | ||
| }, | ||
| "compatible-additional-properties": { |
There was a problem hiding this comment.
I didn't see we enable compatibilityMode option in mgmt plane, will it cause problem?
There was a problem hiding this comment.
No problem for us, I searched in current spec there is no any real additional properties cases yet, that means no extends Record<..> or ...Record<...>.
The case we received for ImpactReporting is a fake case where the payload has the extra layer of additionalProperties explicitly - https://github.com/Azure/azure-rest-api-specs/pull/33352/files#r2011565369.
For long term I would prefer to never turn on compatibilityMode if possible, so finally we could remove this logic and only support for new style which better handles the type check stuff.
fixes #2506
fixes #2471
fixes #2400
design doc
We would have two styles:
Record<T>additionalPropertiesbagAnd we will have following conclusions:
Any complex ser/deser logic is not in-scope