File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
lib/ash_json_api/controllers Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ if Code.ensure_loaded?(OpenApiSpex) do
19
19
20
20
@ doc false
21
21
def spec ( conn , opts ) do
22
- phoenix_endpoint = opts [ :phoenix_endpoint ] || conn [ : private] [ :phoenix_endpoint ]
22
+ phoenix_endpoint = opts [ :phoenix_endpoint ] || conn . private [ :phoenix_endpoint ]
23
23
24
24
opts
25
25
|> Keyword . put ( :phoenix_endpoint , phoenix_endpoint )
Original file line number Diff line number Diff line change 1
1
defmodule Test.Acceptance.OpenApiTest do
2
2
use ExUnit.Case , async: true
3
+ use Plug.Test
3
4
alias OpenApiSpex . { OpenApi , Schema }
4
5
5
6
defmodule Bio do
@@ -253,6 +254,19 @@ defmodule Test.Acceptance.OpenApiTest do
253
254
% { open_api_spec: api_spec }
254
255
end
255
256
257
+ test "spec can be fetched from the controller" , % { open_api_spec: api_spec } do
258
+ assert :get
259
+ |> conn ( "/open_api" )
260
+ |> AshJsonApi.Controllers.OpenApi . call (
261
+ domains: [ Blogs ] ,
262
+ modify_open_api: { __MODULE__ , :modify_open_api , [ ] }
263
+ )
264
+ |> sent_resp ( )
265
+ |> elem ( 2 )
266
+ |> Jason . decode! ( )
267
+ |> Kernel . == ( Jason . decode! ( Jason . encode! ( api_spec ) ) )
268
+ end
269
+
256
270
test "modify option is honored" , % { open_api_spec: api_spec } do
257
271
assert api_spec . info . title == "foobar"
258
272
end
You can’t perform that action at this time.
0 commit comments