Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F74469064
paths.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
paths.ex
View Options
defmodule
OpenApiSpex.Paths
do
@moduledoc
"""
Defines the `OpenApiSpex.Paths.t` type.
"""
alias
OpenApiSpex.PathItem
@typedoc
"""
[Paths Object](https://swagger.io/specification/
#
pathsObject)
Holds the relative paths to the individual endpoints and their operations.
The path is appended to the URL from the Server Object in order to construct the full URL.
The Paths MAY be empty, due to ACL constraints.
"""
@type
t
::
%{
String
.
t
=>
PathItem
.
t
}
@doc
"""
Create a Paths map from the routes in the given router module.
"""
@spec
from_router
(
module
)
::
t
def
from_router
(
router
)
do
router
.
__routes__
()
|>
Enum
.
group_by
(
fn
route
->
route
.
path
end
)
|>
Enum
.
map
(
fn
{
k
,
v
}
->
{
open_api_path
(
k
),
PathItem
.
from_routes
(
v
)}
end
)
|>
Enum
.
filter
(
fn
{
_k
,
v
}
->
!
is_nil
(
v
)
end
)
|>
Map
.
new
()
end
@spec
open_api_path
(
String
.
t
)
::
String
.
t
defp
open_api_path
(
path
)
do
path
|>
String
.
split
(
"/"
)
|>
Enum
.
map
(
fn
":"
<>
segment
->
"{
#{
segment
}
}"
;
segment
->
segment
end
)
|>
Enum
.
join
(
"/"
)
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sat, Apr 25, 1:14 PM (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1310025
Default Alt Text
paths.ex (1 KB)
Attached To
Mode
R22 open_api_spex
Attached
Detach File
Event Timeline
Log In to Comment