Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions openapi_core/contrib/django/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ def __call__(self, request):
openapi_request = self._get_openapi_request(request)
req_result = self.validation_processor.process_request(openapi_request)
if req_result.errors:
return self._handle_request_errors(req_result, request)

request.openapi = req_result

response = self.get_response(request)
response = self._handle_request_errors(req_result, request)
else:
request.openapi = req_result
response = self.get_response(request)

openapi_response = self._get_openapi_response(response)
resp_result = self.validation_processor.process_response(
Expand Down
31 changes: 30 additions & 1 deletion tests/integration/data/v3.0/petstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ paths:
responses:
'200':
$ref: "#/components/responses/PetsResponse"
'400':
$ref: "#/components/responses/ErrorResponse"
'404':
$ref: "#/components/responses/HtmlResponse"
post:
Expand Down Expand Up @@ -403,6 +405,31 @@ components:
default: 400
message:
type: string
StandardError:
type: object
x-model: StandardError
required:
- title
- status
- class
properties:
title:
type: string
status:
type: integer
format: int32
default: 400
class:
type: string
StandardErrors:
type: object
required:
- errors
properties:
errors:
type: array
items:
$ref: "#/components/schemas/StandardError"
ExtendedError:
type: object
x-model: ExtendedError
Expand Down Expand Up @@ -430,7 +457,9 @@ components:
content:
application/json:
schema:
$ref: "#/components/schemas/ExtendedError"
oneOf:
- $ref: "#/components/schemas/StandardErrors"
- $ref: "#/components/schemas/ExtendedError"
HtmlResponse:
description: HTML page
content:
Expand Down