Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aca0c4713e | |||
| 3077195396 | |||
| 94f6ca8c89 | |||
| ae5eeeb600 |
+11
-2
@@ -3,6 +3,17 @@ Changelog
|
||||
#########
|
||||
|
||||
|
||||
*********
|
||||
**1.7.4**
|
||||
*********
|
||||
|
||||
*Release date: May 14, 2018*
|
||||
|
||||
- **IMPROVED:** updated ``swagger-ui`` to version 3.14.2
|
||||
- **IMPROVED:** updated ``ReDoc`` to version 2.0.0-alpha.20
|
||||
- **FIXED:** ignore ``None`` return from ``get_operation`` to avoid empty ``Path`` objects in output
|
||||
- **FIXED:** request body is now allowed on ``DELETE`` endpoints (:issue:`118`)
|
||||
|
||||
*********
|
||||
**1.7.3**
|
||||
*********
|
||||
@@ -11,7 +22,6 @@ Changelog
|
||||
|
||||
- **FIXED:** views whose ``__init__`` methods throw exceptions will now be ignored during endpoint enumeration
|
||||
|
||||
|
||||
*********
|
||||
**1.7.2**
|
||||
*********
|
||||
@@ -21,7 +31,6 @@ Changelog
|
||||
- **FIXED:** fixed generation of default ``SECURITY_REQUIREMENTS`` to match documented behaviour
|
||||
- **FIXED:** ordering of ``SECURITY_REQUIREMENTS`` and ``SECURITY_DEFINITIONS`` is now stable
|
||||
|
||||
|
||||
*********
|
||||
**1.7.1**
|
||||
*********
|
||||
|
||||
Generated
+121
-1610
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "drf-yasg",
|
||||
"dependencies": {
|
||||
"redoc": "^2.0.0-alpha.17",
|
||||
"swagger-ui-dist": "^3.14.1"
|
||||
"redoc": "^2.0.0-alpha.20",
|
||||
"swagger-ui-dist": "^3.14.2"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -324,7 +324,9 @@ class OpenAPISchemaGenerator(object):
|
||||
if not public and not self._gen.has_view_permissions(path, method, view):
|
||||
continue
|
||||
|
||||
operations[method.lower()] = self.get_operation(view, path, prefix, method, components, request)
|
||||
operation = self.get_operation(view, path, prefix, method, components, request)
|
||||
if operation is not None:
|
||||
operations[method.lower()] = operation
|
||||
|
||||
if operations:
|
||||
# since the common prefix is used as the API basePath, it must be stripped
|
||||
|
||||
@@ -276,7 +276,10 @@ class SerializerInspector(FieldInspector):
|
||||
|
||||
|
||||
class ViewInspector(BaseInspector):
|
||||
body_methods = ('PUT', 'PATCH', 'POST') #: methods that are allowed to have a request body
|
||||
body_methods = ('PUT', 'PATCH', 'POST', 'DELETE') #: methods that are allowed to have a request body
|
||||
|
||||
#: methods that are assumed to require a request body determined by the view's ``serializer_class``
|
||||
implicit_body_methods = ('PUT', 'PATCH', 'POST')
|
||||
|
||||
# real values set in __init__ to prevent import errors
|
||||
field_inspectors = [] #:
|
||||
|
||||
@@ -101,7 +101,7 @@ class SwaggerAutoSchema(ViewInspector):
|
||||
if isinstance(body_override, openapi.Schema.OR_REF):
|
||||
return body_override
|
||||
return force_serializer_instance(body_override)
|
||||
elif self.method in self.body_methods:
|
||||
elif self.method in self.implicit_body_methods:
|
||||
return self.get_view_serializer()
|
||||
|
||||
return None
|
||||
@@ -144,8 +144,11 @@ class SwaggerAutoSchema(ViewInspector):
|
||||
raise SwaggerGenerationError("specify the body parameter as a Schema or Serializer in request_body")
|
||||
if any(param.in_ == openapi.IN_FORM for param in manual_parameters): # pragma: no cover
|
||||
if any(param.in_ == openapi.IN_BODY for param in parameters.values()):
|
||||
raise SwaggerGenerationError("cannot add form parameters when the request has a request schema; "
|
||||
raise SwaggerGenerationError("cannot add form parameters when the request has a request body; "
|
||||
"did you forget to set an appropriate parser class on the view?")
|
||||
if self.method not in self.body_methods:
|
||||
raise SwaggerGenerationError("form parameters can only be applied to (" + ','.join(self.body_methods) +
|
||||
") HTTP methods")
|
||||
|
||||
parameters.update(param_list_to_odict(manual_parameters))
|
||||
return list(parameters.values())
|
||||
|
||||
+38
-61
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+35
-12
@@ -33,6 +33,21 @@ class SnippetList(generics.ListCreateAPIView):
|
||||
"""post method docstring"""
|
||||
return super(SnippetList, self).post(request, *args, **kwargs)
|
||||
|
||||
@swagger_auto_schema(
|
||||
operation_id='snippets_delete_bulk',
|
||||
request_body=openapi.Schema(
|
||||
type=openapi.TYPE_OBJECT,
|
||||
properties={
|
||||
'body': openapi.Schema(
|
||||
type=openapi.TYPE_STRING,
|
||||
description='this should not crash (request body on DELETE method)'
|
||||
)
|
||||
}
|
||||
),
|
||||
)
|
||||
def delete(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
class SnippetDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
@@ -56,18 +71,26 @@ class SnippetDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""patch method docstring"""
|
||||
return super(SnippetDetail, self).patch(request, *args, **kwargs)
|
||||
|
||||
@swagger_auto_schema(manual_parameters=[
|
||||
openapi.Parameter(
|
||||
name='id', in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_INTEGER,
|
||||
description="path parameter override",
|
||||
required=True
|
||||
),
|
||||
], responses={
|
||||
status.HTTP_204_NO_CONTENT: openapi.Response(
|
||||
description="This should not crash"
|
||||
)
|
||||
})
|
||||
@swagger_auto_schema(
|
||||
manual_parameters=[
|
||||
openapi.Parameter(
|
||||
name='id', in_=openapi.IN_PATH,
|
||||
type=openapi.TYPE_INTEGER,
|
||||
description="path parameter override",
|
||||
required=True
|
||||
),
|
||||
openapi.Parameter(
|
||||
name='delete_form_param', in_=openapi.IN_FORM,
|
||||
type=openapi.TYPE_INTEGER,
|
||||
description="this should not crash (form parameter on DELETE method)"
|
||||
),
|
||||
],
|
||||
responses={
|
||||
status.HTTP_204_NO_CONTENT: openapi.Response(
|
||||
description="this should not crash (response object with no schema)"
|
||||
)
|
||||
}
|
||||
)
|
||||
def delete(self, request, *args, **kwargs):
|
||||
"""delete method docstring"""
|
||||
return super(SnippetDetail, self).patch(request, *args, **kwargs)
|
||||
|
||||
+23
-1
@@ -388,6 +388,24 @@ paths:
|
||||
$ref: '#/definitions/Snippet'
|
||||
tags:
|
||||
- snippets
|
||||
delete:
|
||||
operationId: snippetsDeleteBulk
|
||||
description: SnippetList classdoc
|
||||
parameters:
|
||||
- name: data
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
body:
|
||||
description: this should not crash (request body on DELETE method)
|
||||
type: string
|
||||
responses:
|
||||
'204':
|
||||
description: ''
|
||||
tags:
|
||||
- snippets
|
||||
parameters: []
|
||||
/snippets/{id}/:
|
||||
get:
|
||||
@@ -442,9 +460,13 @@ paths:
|
||||
description: path parameter override
|
||||
required: true
|
||||
type: integer
|
||||
- name: delete_form_param
|
||||
in: formData
|
||||
description: this should not crash (form parameter on DELETE method)
|
||||
type: integer
|
||||
responses:
|
||||
'204':
|
||||
description: This should not crash
|
||||
description: this should not crash (response object with no schema)
|
||||
tags:
|
||||
- snippets
|
||||
parameters:
|
||||
|
||||
Reference in New Issue
Block a user