Settings are configurable in settings.py
by defining SWAGGER_SETTINGS
or REDOC_SETTINGS
.
Example:
settings.py
SWAGGER_SETTINGS = {
'SECURITY_DEFINITIONS': {
'basic': {
'type': 'basic'
}
},
...
}
REDOC_SETTINGS = {
'LAZY_RENDERING': True,
...
}
The possible settings and their default values are as follows:
~.inspectors.ViewInspector
subclass that will be used by default for generating .Operation
objects when iterating over endpoints. Can be overriden by using the auto_schema argument of @swagger_auto_schema <.swagger_auto_schema>
or by a swagger_schema
attribute on the view class.
Default: drf_yasg.inspectors.SwaggerAutoSchema
List of ~.inspectors.FieldInspector
subclasses that will be used by default for inspecting serializers and serializer fields. Field inspectors given to @swagger_auto_schema <.swagger_auto_schema>
will be prepended to this list.
Default: [
'drf_yasg.inspectors.CamelCaseJSONFilter' <.inspectors.CamelCaseJSONFilter>
, 'drf_yasg.inspectors.ReferencingSerializerInspector' <.inspectors.ReferencingSerializerInspector>
, 'drf_yasg.inspectors.RelatedFieldInspector' <.inspectors.RelatedFieldInspector>
, 'drf_yasg.inspectors.ChoiceFieldInspector' <.inspectors.ChoiceFieldInspector>
, 'drf_yasg.inspectors.FileFieldInspector' <.inspectors.FileFieldInspector>
, 'drf_yasg.inspectors.DictFieldInspector' <.inspectors.DictFieldInspector>
, 'drf_yasg.inspectors.SimpleFieldInspector' <.inspectors.SimpleFieldInspector>
, 'drf_yasg.inspectors.StringDefaultFieldInspector' <.inspectors.StringDefaultFieldInspector>
, ]
List of ~.inspectors.FilterInspector
subclasses that will be used by default for inspecting filter backends. Filter inspectors given to @swagger_auto_schema <.swagger_auto_schema>
will be prepended to this list.
Default: [
'drf_yasg.inspectors.CoreAPICompatInspector' <.inspectors.CoreAPICompatInspector>
, ]
List of ~.inspectors.PaginatorInspector
subclasses that will be used by default for inspecting paginators. Paginator inspectors given to @swagger_auto_schema <.swagger_auto_schema>
will be prepended to this list.
Default: [
'drf_yasg.inspectors.DjangoRestResponsePagination' <.inspectors.DjangoRestResponsePagination>
, 'drf_yasg.inspectors.CoreAPICompatInspector' <.inspectors.CoreAPICompatInspector>
, ]
An import string to an .openapi.Info
object. This will be used when running the generate_swagger
management command, or if no info
argument is passed to get_schema_view
.
Default: None
A string representing the default API URL. This will be used to populate the host
and schemes
attributes of the Swagger document if no API URL is otherwise provided. The Django FORCE_SCRIPT_NAME setting can be used for providing an API mount point prefix.
See also: documentation on base URL construction <custom-spec-base-url>
Default: None
Enable/disable Django login as an authentication/authorization mechanism. If True, a login/logout button will be displayed in Swagger UI.
Default: True
URL for the Django Login action when using USE_SESSION_AUTH.
Default: django.conf.settings.LOGIN_URL
URL for the Django Logout action when using USE_SESSION_AUTH.
Default: django.conf.settings.LOGOUT_URL
Swagger security definitions to be included in the specification. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#security-definitions-object.
Default:
'basic': {
'type': 'basic'
}
Global security requirements. If None
, all schemes in SECURITY_DEFINITIONS
are accepted. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#securityRequirementObject.
Default: None
Swagger UI configuration settings. See https://github.com/swagger-api/swagger-ui/blob/112bca906553a937ac67adc2e500bdeed96d067b/docs/usage/configuration.md#parameters.
URL pointing to a swagger-validator instance; used for the validation badge shown in swagger-ui. Can be modified to point to a local install of swagger-validator or set to None
to remove the badge.
Default: 'http://online.swagger.io/validator/'
Maps to parameter: validatorUrl
Sorting order for the operation list of each tag.
None
: show in the order returned by the serveralpha
: sort alphabetically by pathmethod
: sort by HTTP method
Default: None
Maps to parameter: operationsSorter
Sorting order for tagged operation groups.
None
: Swagger UI default orderingalpha
: sort alphabetically
Default: None
Maps to parameter: tagsSorter
Controls the default expansion setting for the operations and tags.
None
: everything is collapsedlist
: only tags are expandedfull
: all operations are expanded
Default: 'list'
Maps to parameter: docExpansion
Automatically update the fragment part of the URL with permalinks to the currently selected operation.
Default: False
Maps to parameter: deepLinking
Show vendor extension (x-..
) fields.
Default: True
Maps to parameter: showExtensions
Controls whether operations show the model structure or the example value by default.
model
: show the model fields by defaultexample
: show the example value by default
Default: 'model'
Maps to parameter: defaultModelRendering
Controls how many levels are expaned by default when showing nested models.
Default: 3
Maps to parameter: defaultModelExpandDepth
Used when OAuth2 authenitcation of API requests via swagger-ui is desired.
Default: None
Maps to parameter: oauth2RedirectUrl
Used when OAuth2 authenitcation of API requests via swagger-ui is desired. Provides OAuth2 configuration parameters to the SwaggerUIBundle#initOAuth
method, and must be a dictionary. See OAuth2 configuration.
Default: {}
ReDoc UI configuration settings. See https://github.com/Rebilly/ReDoc#redoc-tag-attributes.
Default: True
Maps to attribute: lazy-rendering
Default: False
Maps to attribute: hide-hostname
Default: 'all'
Maps to attribute: expand-responses
Default: False
Maps to attribute: path-in-middle-panel