autorest
autorest copied to clipboard
Is it possible to include/exclude paths/operations + models?
I am using autorest to generate a c# client for an application our group is building. We are actually using only a small subset of endpoints/models defined in the api spec.
Ideally, we'd like to pick the endpoints we want to use, then trim the models to only include those that are needed by those endpoints. Is anything along those lines possible?
You can use directives to remove operations See docs
there is a set of built-in directives which might be useful remove-operation
in particular.
You can use directives to remove operations See docs
there is a set of built-in directives which might be useful
remove-operation
in particular.
Is it possible to automatically prune models not used in the current operations? Or is it possible to list the models used by an operation (including nested models). Or anything else that could help me safely delete a large number of models/operations?
There currently isn't a way to remove unused models. One of the issue is that a spec could have unreferenced models that aren't really unused. In Swagger 2.0 as you couldn't do oneOf
the workaround would just to have the definitions there(unreferenced) and mark the type as any
but you do need those definitions to be in the generated SDK.
This is maybe a feature we could look into adding as a toggle but not planned right now.
somewhat related: https://github.com/Azure/autorest/issues/4456
this would also help us in an API first process, because the API that the swagger defines is not necessarily implemented by a single service, so it would be great to pick and choose/ slice the operations and models to include in a generation without having to split the swagger files accordingly