diff --git a/bin/build-openapi-yaml.rb b/bin/build-openapi-yaml.rb index c538ea645..dc0a6c91c 100755 --- a/bin/build-openapi-yaml.rb +++ b/bin/build-openapi-yaml.rb @@ -277,11 +277,9 @@ def addListValue(hash, key, listElementType, identity_providers, rootkey = nil, end end -def param_optional(comments_arr) - if comments_arr && comments_arr[0].include?("(Optional)") - return true - end - return false +# Returns true if the 1st comment includes (Optional) +def param_optional(param) + param['comments']&.[](0)&.include?("(Optional)") end def process_rawpaths(rawpaths, options) @@ -347,7 +345,7 @@ def process_api_file(fn, paths, options, deferred) next end - if param_optional(p["comments"]) + if param_optional(p) uri = uri + "/{" + p["name"] + "}" else uri = uri + "/{" + p["name"] + "}" @@ -508,7 +506,7 @@ def build_path(uri, json, paths, include_optional_segment_param, options) next end - if param_optional(p["comments"]) + if param_optional(p) if include_optional_segment_param # we have an optional param but it is in the URI, so we want to add it to the parameters params << build_openapi_paramobj(p, "path") @@ -576,12 +574,24 @@ def build_openapi_paramobj(jsonparamobj, paramtype) paramobj = {} paramobj["name"] = jsonparamobj["name"] paramobj["in"] = paramtype - paramobj["schema"] = {} - paramobj["schema"]["type"] = "string" + # Cover Java generics here + paramobj["schema"] = if %w[Collection List Set].include? jsonparamobj['javaType'] + { + 'type' => 'array', + 'items' => { + 'type' => 'string' + } + } + else + { 'type' => 'string' } + end if paramtype == "path" paramobj["required"] = true end + if jsonparamobj['optional'] + paramobj['required'] = false + end if jsonparamobj["comments"] && jsonparamobj["comments"][0] paramobj["description"] = jsonparamobj["comments"].join(" ").gsub('(Optional)', '').gsub("\n", '').delete("\n").strip end diff --git a/src/main/api/retrieveUserByLoginId.json b/src/main/api/retrieveUserByLoginId.json index e2380eaa7..d86b4f934 100644 --- a/src/main/api/retrieveUserByLoginId.json +++ b/src/main/api/retrieveUserByLoginId.json @@ -18,4 +18,4 @@ "javaType": "String" } ] -} \ No newline at end of file +} diff --git a/src/main/api/retrieveUserByLoginIdWithLoginIdTypes.json b/src/main/api/retrieveUserByLoginIdWithLoginIdTypes.json new file mode 100644 index 000000000..343d90971 --- /dev/null +++ b/src/main/api/retrieveUserByLoginIdWithLoginIdTypes.json @@ -0,0 +1,30 @@ +{ + "uri": "/api/user", + "comments": [ + "Retrieves the user for the loginId, using specific loginIdTypes." + ], + "method": "get", + "methodName": "retrieveUserByLoginIdWithLoginIdTypes", + "successResponse": "UserResponse", + "errorResponse": "Errors", + "params": [ + { + "name": "loginId", + "comments": [ + "The email or username of the user." + ], + "type": "urlParameter", + "parameterName": "loginId", + "javaType": "String" + }, + { + "name": "loginIdTypes", + "comments": [ + "the identity types that FusionAuth will compare the loginId to." + ], + "type": "urlParameter", + "parameterName": "loginIdTypes", + "javaType": "List" + } + ] +} diff --git a/src/main/api/retrieveUserLoginReportByLoginId.json b/src/main/api/retrieveUserLoginReportByLoginId.json index 7adfc5ad8..e36b93ad0 100644 --- a/src/main/api/retrieveUserLoginReportByLoginId.json +++ b/src/main/api/retrieveUserLoginReportByLoginId.json @@ -46,4 +46,4 @@ "javaType": "long" } ] -} \ No newline at end of file +} diff --git a/src/main/api/retrieveUserLoginReportByLoginIdAndLoginIdTypes.json b/src/main/api/retrieveUserLoginReportByLoginIdAndLoginIdTypes.json new file mode 100644 index 000000000..5417cf732 --- /dev/null +++ b/src/main/api/retrieveUserLoginReportByLoginIdAndLoginIdTypes.json @@ -0,0 +1,58 @@ +{ + "uri": "/api/report/login", + "comments": [ + "Retrieves the login report between the two instants for a particular user by login Id, using specific loginIdTypes. If you specify an application id, it will only return the", + "login counts for that application." + ], + "method": "get", + "methodName": "retrieveUserLoginReportByLoginIdAndLoginIdTypes", + "successResponse": "LoginReportResponse", + "errorResponse": "Errors", + "params": [ + { + "name": "applicationId", + "comments": [ + "(Optional) The application id." + ], + "type": "urlParameter", + "parameterName": "applicationId", + "javaType": "UUID" + }, + { + "name": "loginId", + "comments": [ + "The userId id." + ], + "type": "urlParameter", + "parameterName": "loginId", + "javaType": "String" + }, + { + "name": "start", + "comments": [ + "The start instant as UTC milliseconds since Epoch." + ], + "type": "urlParameter", + "parameterName": "start", + "javaType": "long" + }, + { + "name": "end", + "comments": [ + "The end instant as UTC milliseconds since Epoch." + ], + "type": "urlParameter", + "parameterName": "end", + "javaType": "long" + }, + { + "name": "loginIdTypes", + "comments": [ + "the identity types that FusionAuth will compare the loginId to." + ], + "type": "urlParameter", + "parameterName": "loginIdTypes", + "javaType": "List" + } + ] +} diff --git a/src/main/client/_macros.ftl b/src/main/client/_macros.ftl index f52d0400b..941747a44 100644 --- a/src/main/client/_macros.ftl +++ b/src/main/client/_macros.ftl @@ -33,8 +33,8 @@ [#case "KeyType"][#return "KeyType?"/] [#case "KeyAlgorithm"][#return "KeyAlgorithm?"/] [#default] - [#if type?starts_with("Collection")] - [#return type?replace("Collection", "List")?replace("UUID", "string")/] + [#if type?starts_with("Collection") || type?starts_with("List")] + [#return type?replace("Collection", "List")?replace("UUID", "string")?replace("String", "string")/] [#else] [#return type/] [/#if] @@ -52,8 +52,8 @@ [#return "int64"/] [#elseif type == "Void"] [#return "nil"/] - [#elseif type?starts_with("Collection")] - [#return type?replace("Collection", "[]")?replace("UUID", "string")?replace("<", "")?replace(">", "")/] + [#elseif type?starts_with("Collection<") || type?starts_with("List<")] + [#return type?replace("Collection", "[]")?replace("List", "[]")?replace("UUID", "string")?replace("<", "")?replace(">", "")?replace("String", "string")/] [#elseif type == "String" || type = "UUID" || type == "ZoneId" || type == "URI" || type == "Locale" || type == "LocalDate" || type == "char" || type == "IdentityType" ] [#return "string"/] [#elseif type == "Object" || type == "D" || type == "T"] @@ -97,7 +97,7 @@ [#case "JWT"][#return "JWT | object"/] [#case "Void"][#return "void"/] [#default] - [#if type?starts_with("Collection")] + [#if type?starts_with("Collection<") || type?starts_with("List<")] [#return type?replace("Collection", "Array")?replace("UUID", "string")/] [#else] [#return type/] @@ -132,8 +132,8 @@ [#case "Object"][#return "any"/] [#case "Void"][#return "void"/] [#default] - [#if type?starts_with("Collection")] - [#return type?replace("Collection", "Array")?replace("UUID", "string")/] + [#if type?starts_with("Collection<") || type?starts_with("List<")] + [#return type?replace("Collection", "Array")?replace("List", "Array")?replace("UUID", "string")/] [#else] [#return type/] [/#if] @@ -155,7 +155,7 @@ [#elseif language == "ruby"] [#if type == "UUID" || type == "String" || type == "IdentityProviderType" || type == "LambdaType"] [#return "string"/] - [#elseif type?starts_with("Collection")] + [#elseif type?starts_with("Collection<") || type?starts_with("List<")] [#return "Array"/] [#elseif type == "boolean" || type == "Boolean"] [#return "Boolean"/]