@@ -31,6 +31,7 @@ import Data.Aeson hiding (Array, Bool, Object, String)
31import qualified Data.Aeson as A
31import qualified Data.Aeson as A
32import Data.Aeson.TH
32import Data.Aeson.TH
33import Data.Aeson.Types (Parser)
33import Data.Aeson.Types (Parser)
34+import Data.Foldable (foldMap)
34import Data.Function (on)
35import Data.Function (on)
35import qualified Data.HashMap.Strict as Map
36import qualified Data.HashMap.Strict as Map
36import Data.Maybe
37import Data.Maybe
@@ -437,11 +438,13 @@ serviceName :: Service a -> String
437serviceName = Text.unpack . (<> "Service") . toCamel . _sCanonicalName
438serviceName = Text.unpack . (<> "Service") . toCamel . _sCanonicalName
439scopeName :: Service a -> Text -> String
440scopeName :: Service a -> Text -> String
441− let y = _sCanonicalName s <> "AllScope"
442− in Text.unpack . toCamel $
441+scopeName s k = Text.unpack . toCamel $
443− case Text.split (== '/') k of
442+ case parts of
444− [] -> y
443+ [] -> _sCanonicalName s <> "AllScope"
445− xs -> case last xs of
444+ xs -> foldMap upperHead xs <> "Scope"
447− x -> x <> "Scope"
446+ parts = filter (not . url) (Text.split (== '/') k)
449+ || Text.isPrefixOf "http" x
450+ || Text.isPrefixOf "www" x