From 82d37d8e1a152d7c9d8fe36661fa23571286c74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Mon, 4 Mar 2024 10:36:17 +0100 Subject: [PATCH] Set "Requires Authentication: Optional" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- layouts/partials/openapi/render-operation.html | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/layouts/partials/openapi/render-operation.html b/layouts/partials/openapi/render-operation.html index 4c004c27..253e2efe 100644 --- a/layouts/partials/openapi/render-operation.html +++ b/layouts/partials/openapi/render-operation.html @@ -60,21 +60,22 @@ Requires authentication: {{/* - Authentication is optional if one of these is true: - - the security key is not set - - the security value contains an empty object + Authentication is defined with the `security` key. We assume that the + key is not set if no authentication is necessary. If the key is set, + authentication is required unless it contains an item that is an empty + object. */}} - {{ $requires_authentication := 1 }} + {{ $requires_authentication := "Yes" }} {{ if $operation_data.security }} {{ range $operation_data.security }} {{ if eq (len (index $operation_data.security 0)) 0 }} - {{ $requires_authentication = 0 }} + {{ $requires_authentication = "Optional" }} {{ end }} {{ end }} {{ else }} - {{ $requires_authentication = 0 }} + {{ $requires_authentication = "No" }} {{ end }} - {{ if $requires_authentication }}Yes{{ else }}No{{ end }} + {{ $requires_authentication }}