Skip to content

Commit 6fb9210

Browse files
committed
chore: move require Logger to module level
Move the require Logger statement to module level for cleaner code organization and remove accidental error logging that referenced undefined variable.
1 parent 170749d commit 6fb9210

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/ash_json_api/json_schema/open_api.ex

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ if Code.ensure_loaded?(OpenApiSpex) do
5050
Tag
5151
}
5252

53+
require Logger
54+
5355
@typep content_type_format() :: :json | :multipart
5456
@typep acc() :: map()
5557

@@ -948,7 +950,6 @@ if Code.ensure_loaded?(OpenApiSpex) do
948950
if type_key in acc.seen_non_schema_types do
949951
# We're in a recursive loop, return $ref and warn
950952
# Recursive type detected, using $ref instead of inline definition
951-
require Logger
952953

953954
Logger.warning(
954955
"Detected recursive embedded type with JSON API type: #{inspect(instance_of)}"
@@ -1080,9 +1081,9 @@ if Code.ensure_loaded?(OpenApiSpex) do
10801081
input_schema_name =
10811082
create_input_schema_name(attribute, parent_resource, action_type, embedded_resource)
10821083

1083-
# Check for recursion
10841084
type_key = {embedded_resource, action_type, attribute.constraints}
10851085

1086+
# Check for recursion
10861087
if type_key in acc.seen_input_types do
10871088
# We're in a recursive loop
10881089
if input_schema_name do
@@ -1545,10 +1546,8 @@ if Code.ensure_loaded?(OpenApiSpex) do
15451546
{parameters_list, acc} = parameters(route, resource, path_params, acc)
15461547
{response, acc} = response_body(route, resource, acc)
15471548

1548-
# Get request body and any generated schemas
15491549
{request_body_result, request_schemas} = request_body(route, resource)
15501550

1551-
# Merge request schemas into accumulator
15521551
acc_with_request_schemas = %{acc | schemas: Map.merge(acc.schemas, request_schemas)}
15531552

15541553
operation = %Operation{
@@ -2013,7 +2012,6 @@ if Code.ensure_loaded?(OpenApiSpex) do
20132012
{multipart_body_schema, multipart_acc} =
20142013
request_body_schema(route, resource, :multipart, empty_acc())
20152014

2016-
# Collect all generated schemas
20172015
all_schemas = Map.merge(json_acc.schemas, multipart_acc.schemas)
20182016

20192017
body =
@@ -2064,7 +2062,6 @@ if Code.ensure_loaded?(OpenApiSpex) do
20642062
}
20652063
end
20662064

2067-
# Return both the body and any generated schemas
20682065
{body, all_schemas}
20692066
end
20702067

0 commit comments

Comments
 (0)