Documentation ¶
Index ¶
- Constants
- func AtoiOrPanic(str string) int
- func CheckDuplicatedTitleTypes(apiDef *raml.APIDefinition) error
- func DenormalizePkgName(name string) string
- func DisplayNameToFuncName(str string) string
- func GenerateFile(data interface{}, tmplFile, tmplName, filename string, override bool) error
- func GetBasicType(t string) string
- func HasJSONBody(body *raml.Bodies) bool
- func IsArrayType(t string) bool
- func IsBuiltinType(t interface{}) bool
- func IsJSONString(s string) bool
- func IsStrInArray(arr []string, str string) bool
- func MapToSortedStrings(m map[string]struct{}) []string
- func NormalizeIdentifier(s string) string
- func NormalizeIdentifierWithLib(s string, apiDef *raml.APIDefinition) string
- func NormalizePkgName(name string) string
- func NormalizeURI(URI string) string
- func NormalizeURITitle(URI string) string
- func ParamizingURI(URI, sep string) string
- func ParseDescription(desc string) []string
- func SnackCaseServerMethodName(displayName, verb string, resource *raml.Resource) string
Constants ¶
const ( // ReqBodySuffix is suffix name for request body object ReqBodySuffix = "ReqBody" // RespBodySuffix is suffix name for response body object RespBodySuffix = "RespBody" )
Variables ¶
This section is empty.
Functions ¶
func AtoiOrPanic ¶
AtoiOrPanic convert a string to int and panic if failed
func CheckDuplicatedTitleTypes ¶
func CheckDuplicatedTitleTypes(apiDef *raml.APIDefinition) error
CheckDuplicatedTitleTypes checks that the API definition has duplicated types of the title case version of the types. title case = first letter become uppercase example of non duplicate:
- One & Two
- One & oNe = One & ONe -> N is uppercase
example of duplicate - One & one = One & One
func DisplayNameToFuncName ¶
func GenerateFile ¶
GenerateFile generates file from a template. if file already exist and override==false, file won't be regenerated funcMap = this parameter is used for passing go function to the template
func GetBasicType ¶
GetBasicType returns basic type of a basic or complex type
func HasJSONBody ¶
HasJSONBody checks if this raml.Bodies has JSON body that need to be generated it's struct. rules:
- not nil application/json
- has properties or has tipe in JSON string
func IsArrayType ¶
IsArrayType returns true if the given string is a RAML array
func IsBuiltinType ¶
func IsBuiltinType(t interface{}) bool
IsBuiltinType returns true if the given type is builtin type
func IsJSONString ¶
IsJSONString returns true if a string is a JSON string
func IsStrInArray ¶
IsStrInArray check if a string `str` is part of array `arr`
func MapToSortedStrings ¶
MapToSortedStrings returns sorted string arrays from a map
func NormalizeIdentifier ¶
NormalizeIdentifier change invalid character in identifier to `_`. Edge cases: - If started with invalid char, we prepend with `The_` - don't replace `.` if it means a library
func NormalizeIdentifierWithLib ¶
func NormalizeIdentifierWithLib(s string, apiDef *raml.APIDefinition) string
func NormalizePkgName ¶
normalize package name because not all characters can be used as package name
func NormalizeURI ¶
NormalizeURI removes `{`, `}`, `/`, and space from an URI
func NormalizeURITitle ¶
NormalizeURITitle does NormalizeURI with first character in upper case
func ParamizingURI ¶
ParamizingURI creates parameterized URI Input : raw string, ex : /users/{userId}/address/{addressId} Output : "/users/"+userId+"/address/"+addressId TODO : optimize with regex
func ParseDescription ¶
ParseDescription create string slice from an RAML description. each element is a description line
Types ¶
This section is empty.