Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions bin/build-openapi-yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"] + "}"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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<String> List<String> Set<String>].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
Expand Down
2 changes: 1 addition & 1 deletion src/main/api/retrieveUserByLoginId.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"javaType": "String"
}
]
}
}
30 changes: 30 additions & 0 deletions src/main/api/retrieveUserByLoginIdWithLoginIdTypes.json
Original file line number Diff line number Diff line change
@@ -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<String>"
}
]
}
2 changes: 1 addition & 1 deletion src/main/api/retrieveUserLoginReportByLoginId.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
"javaType": "long"
}
]
}
}
58 changes: 58 additions & 0 deletions src/main/api/retrieveUserLoginReportByLoginIdAndLoginIdTypes.json
Original file line number Diff line number Diff line change
@@ -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<String>"
}
]
}
16 changes: 8 additions & 8 deletions src/main/client/_macros.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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")/]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In .NET the collection generic is string not String. 1st time we've had to do this in a URL param.

[#else]
[#return type/]
[/#if]
Expand All @@ -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"]
Expand Down Expand Up @@ -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/]
Expand Down Expand Up @@ -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]
Expand All @@ -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"/]
Expand Down