feat: improve error response when the requested schema is invalid

- It now shows the invalid schema in the "message"
- The exposed schemas are now listed in the "hint" instead of the "message"
This commit is contained in:
Laurence Isla
2025-09-14 13:37:17 -05:00
committed by Steve Chavez
parent a4927141ee
commit 4ba6b1b30c
4 changed files with 17 additions and 10 deletions
+1 -1
View File
@@ -207,7 +207,7 @@ getAction resource schema method =
getSchema :: AppConfig -> RequestHeaders -> ByteString -> Either ApiRequestError (Schema, Bool)
getSchema AppConfig{configDbSchemas} hdrs method = do
case profile of
Just p | p `notElem` configDbSchemas -> Left $ UnacceptableSchema $ toList configDbSchemas
Just p | p `notElem` configDbSchemas -> Left $ UnacceptableSchema p $ toList configDbSchemas
| otherwise -> Right (p, True)
Nothing -> Right (defaultSchema, length configDbSchemas /= 1) -- if we have many schemas, assume the default schema was negotiated
where