autorest.typescript
autorest.typescript copied to clipboard
[Feature] Adding Override features in Typespec that can be applied to multiple items
With the previous Swagger based SDK, we were able to select multiple items in the swagger and override them. This override could be naming overrides, type overrides, required/optional overrides, etc. Sometimes, these overrides are generic to all languages. At other times, they are specific to some languages.
But, with the latest Typespec based SDK, we lost that ability. It is a very useful feature and should be added with the Typespec generator also.
Let us take a look at the following override:
directive:
- from: swagger-document
where: $.definitions
transform: >
for (const definition in $) {
if ($[definition].properties && $[definition].required === undefined) {
const properties = Object.keys($[definition].properties);
if (properties.length > 0) {
switch (definition) {
case "CommunicationIdentifierModel":
$[definition].required = ["rawId"];
break;
default:
$[definition].required = properties;
}
}
}
}
The above swagger override has been applied to JS alone. (This is just an example) Now if I want to apply the same overrides in Typespec, it needs ~1000 lines of code which is really cumbersome.
@xirzec @joheredi FYI.....