diff --git a/src/PostgREST/App.hs b/src/PostgREST/App.hs index e3088b368..25c6f090f 100644 --- a/src/PostgREST/App.hs +++ b/src/PostgREST/App.hs @@ -208,8 +208,9 @@ app dbStructure conf apiRequest = host = configHost conf port = toInteger $ configPort conf encodeFn = if contentType == OpenAPI then encodeApi . toTableInfo else encode + header = if contentType == OpenAPI then openapiH else jsonH body <- encodeFn <$> H.query schema accessibleTables - return $ responseLBS status200 [jsonH] $ cs body + return $ responseLBS status200 [header] $ cs body (ActionInappropriate, _, _) -> return $ responseLBS status405 [] "" @@ -286,6 +287,9 @@ contentRangeH frm to total = jsonH :: Header jsonH = (hContentType, "application/json; charset=utf-8") +openapiH :: Header +openapiH = (hContentType, "application/openapi+json; charset=utf-8") + formatRelationError :: Text -> Text formatRelationError = formatGeneralError "could not find foreign keys between these entities"