On the generated swagger page in the Model
section, how does one get Swashbuckle to not report the whole namespace, but just the model?
MyNamespace.SubFolder.MyModel
to
MyModel
If you mark field/property as internal or protected or private , it will be ignored automatically by swashbuckle in swagger documentation. Update: Obviously, those properties/fields won't be populated in request/response.
Using @ApiParam. @ApiParam is also a Swagger annotation that we can use to specify metadata related to request parameters. We can set the hidden property to true in order to hide any property.
To hide the "Models" section, add defaultModelsExpandDepth: -1 to the Swagger UI configuration code in your index. html . Note the option name uses plural Model*s* not Model . Swagger UI also has many other configuration options that control API documentation rendering.
How to do it? add this property in your Swagger UI Options defaultModelsExpandDepth: -1 for hide schema section and for more reference refer this swagger.io/docs/open-source-tools/swagger-ui/usage/… Can you please add your swagger ui configuration settings in your question.
You should be able to define custom schema id's either through an ISchemaFilter
or create your own "schema id strategy" read: Customizing Schema Id's
services.AddSwaggerGen(c => { ... c.CustomSchemaIds((type) => type.FullName); };
You could create a base model class that contains a name property (remember to [JsonIgnore]
) use that property for the strategy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With