{-# LANGUAGE OverloadedStrings #-}
module Databrary.Controller.API
  ( viewSwagger
  ) where

import Databrary.Has
import Databrary.HTTP.Path.Parser
import Databrary.Action.Types
import Databrary.Action
import Databrary.Routes.API (swagger)

viewSwagger :: ActionRoute API
viewSwagger = action GET (pathAPI </< "swagger") $ \api -> withoutAuth $
  case api of
    HTML -> peeks notFoundResponse
    JSON -> return $ okResponse [] swagger

{-# LANGUAGE OverloadedStrings #-}
module Databrary.Controller.API
  ( viewSwagger
  ) where

import Databrary.Has
import Databrary.HTTP.Path.Parser
import Databrary.Action.Types
import Databrary.Action
import Databrary.Routes.API (swagger)

viewSwagger :: ActionRoute API
viewSwagger = action GET (pathAPI </< "swagger") $ \api -> withoutAuth $
  case api of
    HTML -> peeks notFoundResponse
    JSON -> return $ okResponse [("Access-Control-Allow-Origin","*")] swagger

Add Access-Control-Allow-Origin: * to /api/swagger.json
Add Access-Control-Allow-Origin: * to /api/swagger.json
