autorest icon indicating copy to clipboard operation
autorest copied to clipboard

`remove-parameter` doesn't work on `$ref`'d parameters

Open heaths opened this issue 2 years ago • 4 comments

For common parameters, it's often common to put them in the parameters section, but then that seems to prevent remove-parameter from working. I've also seen a few other cases where transforms may not work because not all (any?) $refs have been resolved. Seems transforms shouldn't have to worry about this, though I've had to on several occasions. This makes transforms less resilient.

heaths avatar Jun 18 '22 00:06 heaths

Directive are simple transforms running a given node, doing ref resolution is much more complex, this would also probably have unexpected consequence where you'd expect the parmeter to only be modified for a single operation and it ends up changing the parameter for all

timotheeguerin avatar Jun 20 '22 15:06 timotheeguerin

But shouldn't transforms work over the fully-resolved swagger? I would expect all $refs to have already been flattened by then. It'd be a lot of extra work to have transforms (wrapped in friendly directives like remote-parameter or otherwise) to have to take both syntaxes into account.

/cc @tg-msft

heaths avatar Jun 20 '22 16:06 heaths

no transforms runs immediately after swagger is loaded. The merged swagger makes no sense to a user, every definition has been renamed to prevent collision and it wouldn't be a good place to run transforms. Including that feature which would require a lot of logic to be included in the directive itself, would also not work if the refs are cross files(Directives are un in the scope of a single file and have no idea about others) so don't see this being added as ultimately will get complains that this only work in some scenarios.

timotheeguerin avatar Jun 20 '22 16:06 timotheeguerin

you can always declare your own reusable directive that fits your scenario and makes it easier to consume it later

timotheeguerin avatar Jun 20 '22 16:06 timotheeguerin