rest-gen 0.17.1.3 → 0.18.0.0
raw patch · 3 files changed
+42/−3 lines, 3 filesdep ~aesonPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson
API changes (from Hackage documentation)
Files
- CHANGELOG.md +9/−0
- rest-gen.cabal +1/−1
- src/Rest/Gen/JavaScript.hs +32/−2
CHANGELOG.md view
@@ -1,5 +1,14 @@ # Changelog +## 0.18.0.0++* Javascript: postfix reserved words with an underscore. This is a+ breaking change for javascript clients, since the generated API code+ will change, so callers might have to be updated. All functions that+ match one of the reserved words from [this+ list](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords)+ will have to be updated with a trailing underscore.+ #### 0.17.1.3 * Javascript: generate new API instance every time. Some properties
rest-gen.cabal view
@@ -1,5 +1,5 @@ name: rest-gen-version: 0.17.1.3+version: 0.18.0.0 description: Documentation and client generation from rest definition. synopsis: Documentation and client generation from rest definition. maintainer: code@silk.co
src/Rest/Gen/JavaScript.hs view
@@ -128,14 +128,44 @@ mkJsName item = case mkFuncParts item of [] -> ""- (x : xs) -> x ++ concatMap upFirst xs+ (x : xs) ->+ let res = x ++ concatMap upFirst xs+ in if res `elem` reservedWords+ then res ++ "_"+ else res jsDir :: [String] -> String jsDir = concatMap upFirst jsId :: [String] -> String jsId [] = ""-jsId (x : xs) = x ++ concatMap upFirst xs+jsId (x : xs) =+ let res = x ++ concatMap upFirst xs+ in if res `elem` reservedWords+ then res ++ "_"+ else res++-- | Javascript reserved words in the broadest sense.+-- Taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords++reservedWords :: [String]+reservedWords = es6Reserved ++ futureReserved ++ futureReservedStrict ++ oldFutureReserved+ ++ reservedLiterals+ where+ es6Reserved =+ [ "break", "case", "class", "catch", "const", "continue", "debugger", "default", "delete"+ , "do", "else", "export", "extends", "finally", "for", "function", "if", "import", "in"+ , "instanceof", "let", "new", "return", "super", "switch", "this", "throw", "try", "typeof"+ , "var", "void", "while", "with", "yield"+ ]+ futureReserved = ["enum", "await"]+ futureReservedStrict =+ [ "implements", "package", "protected", "static", "interface", "private", "public" ]+ oldFutureReserved =+ [ "abstract", "boolean", "byte", "char", "double", "final", "float", "goto", "int", "long"+ , "native", "short", "synchronized", "transient", "volatile"+ ]+ reservedLiterals = ["null", "false", "true"] mkType :: DataType -> (String, String, Code -> Code) mkType dt =