I\'m trying to adjust the \"displayName\" of the model being used in an automatically generated Swagger definition.
This will only affect the Swagger names, meaning the
The answer is: use an IDocumentFilter:
private class ApplyDocumentFilter_ChangeCompany : IDocumentFilter
{
public void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer)
{
if (swaggerDoc.definitions != null)
{
swaggerDoc.definitions.Add("Company123", swaggerDoc.definitions["Company"]);
}
if (swaggerDoc.paths != null)
{
swaggerDoc.paths["/api/Company"].get.responses["200"].schema.@ref = "#/definitions/Company123";
}
}
}
Here is the code: https://github.com/heldersepu/SwashbuckleTest/commit/671ce648a7cc52290b4ad29ca540b476e65240e6
And here is the final result: http://swashbuckletest.azurewebsites.net/swagger/ui/index#!/Company/Company_Get