Koha-clms/api
Lari Taskula c42848609c
Bug 38365: Make swagger-cli happy
Schema type [array,object] is not valid in OpenAPI version 2.

There are two different CSP reporting directives.

One is the now deprecated "report-uri" directive. Browsers typically send a single
JSON object following the CSP2 specification.

"report-uri" is deprecated in CSP3 in favor of the newer "report-to" directive. It
is expected to contain an array of report objects.

There are browser that do not yet support the "report-to" directive, so both
directives should be supported.

There are also variations among the "report-uri" format. See
https://www.tollmanz.com/content-security-policy-report-samples/

Because of these variations, it becomes quite complex to handle the most common
cases in a single API endpoint.

We could build two separate endpoints for both directives.

Or we can accept any type of input and handle the variations in a single endpoint.
This patch attempts to do that.

Before this patch input parameters were validated by JSON::Validator. That is the
normal and recommended way to build OpenAPI endpoints in Koha. After this patch we
remove all input parameter restrictions from the OpenAPI spec, and simply accept
any type of body.

This means the controller will now always return a HTTP 204 regardless of the type
of data passed to the controller. It instead truncates too long input before
writing them into log files.

As this is not an endpoint that developers will build new Koha clients for, we
do not have to offer a very in-depth input parameter spec for this endpoint.

To test:
1. t/db_dependent/api/v1/public/csp_reports.t

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:37 +01:00
..
v1 Bug 38365: Make swagger-cli happy 2026-03-16 11:57:37 +01:00
swagger-v2-schema.json Bug 23653: use local copy of swagger v2 schema 2020-08-26 14:26:29 +02:00