Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix Swagger/OpenAPI custom errors and bump ory/herodot
Previously, the Swagger and OpenAPI specs would incorrectly describe specific errors returned from Kratos' API. Instead of having a nested "error" key in the returned JSON payload, the API specs would incorrectly say the contents of the generic error were flattened into the payload. Example before (incorrect): { "id": "browser_location_change_required", "code": 422, "status": "Unprocessable Entity", "reason": "In order to complete this flow please redirect the browser to: /ui/settings?flow=22b3ad6f-c50a-4c2f-8c94-a16e9dc20083", "message": "browser location change required", "redirect_browser_to": "/ui/settings?flow=22b3ad6f-c50a-4c2f-8c94-a16e9dc20083" } Actual Kratos response (correct, unchanged): { "error": { "id": "browser_location_change_required", "code": 422, "status": "Unprocessable Entity", "reason": "In order to complete this flow please redirect the browser to: /ui/settings?flow=22b3ad6f-c50a-4c2f-8c94-a16e9dc20083", "message": "browser location change required" }, "redirect_browser_to": "/ui/settings?flow=22b3ad6f-c50a-4c2f-8c94-a16e9dc20083" } This issue occurs because go-swagger does not interpret embedded structs with `json` structs correctly, i.e., it flattens the embedded struct's fields into outer type instead of nesting it under the key specified in the `json` tag. The least bad fix is to use modified copies of the affected error structs just for Swagger API spec generation.
- Loading branch information