From 22a7139c9af58c0cfd08a1185fd84a961e8a6794 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Wed, 3 Jan 2024 14:15:28 +0100 Subject: [PATCH] Provide all fixed field names for the components object The OpenAPI components object (https://swagger.io/specification/\#components-object) is used to store schema definitions that can be referred to using the pattern, encouraging re-use. drf-spectacular only uses the 'schemas' and 'securitySchemes' properties internally, but extension developers may wish to use the remaining properties, so they are provided as a convenience. Note that the 'pathItems' property was added in OpenAPI 3.1.0. --- drf_spectacular/plumbing.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drf_spectacular/plumbing.py b/drf_spectacular/plumbing.py index f6c8d5c3..1595271b 100644 --- a/drf_spectacular/plumbing.py +++ b/drf_spectacular/plumbing.py @@ -680,8 +680,18 @@ def alpha_operation_sorter(endpoint): class ResolvedComponent: + # OpenAPI 3.0.3 SCHEMA = 'schemas' + RESPONSE = 'responses' + PARAMETER = 'parameters' + EXAMPLE = 'examples' + REQUEST_BODY = 'requestBodies' + HEADER = 'headers' SECURITY_SCHEMA = 'securitySchemes' + LINK = 'links' + CALLBACK = 'callbacks' + # OpenAPI 3.1.0+ + PATH_ITEM = 'pathItems' def __init__(self, name, type, schema=None, object=None): self.name = name