Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F111933
encode_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
encode_test.exs
View Options
defmodule
OpenApiSpex.EncodeTest
do
use
ExUnit.Case
alias
OpenApiSpex
.
{
Info
,
OpenApi
}
test
"Vendor extensions x-logo properly encoded"
do
spec
=
%
OpenApi
{
info
:
%
Info
{
title
:
"Test"
,
version
:
"1.0.0"
,
extensions
:
%{
"x-logo"
=>
%{
"url"
=>
"https://example.com/logo.png"
,
"backgroundColor"
=>
"
#
FFFFFF"
,
"altText"
=>
"Example logo"
}
}
},
paths
:
%{}
}
decoded
=
OpenApiSpex
.
resolve_schema_modules
(
spec
)
|>
Jason
.
encode!
()
|>
Jason
.
decode!
()
assert
decoded
[
"info"
][
"x-logo"
][
"url"
]
==
"https://example.com/logo.png"
assert
decoded
[
"info"
][
"x-logo"
][
"backgroundColor"
]
==
"
#
FFFFFF"
assert
decoded
[
"info"
][
"x-logo"
][
"altText"
]
==
"Example logo"
assert
is_nil
(
decoded
[
"info"
][
"extensions"
])
end
test
"Vendor extensions x-tagGroups properly encoded"
do
spec
=
%
OpenApi
{
info
:
%
Info
{
title
:
"Test"
,
version
:
"1.0.0"
},
extensions
:
%{
"x-tagGroups"
=>
[
%{
"name"
=>
"Methods"
,
"tags"
=>
[
"Search"
,
"Fetch"
,
"Delete"
]
}
]
},
paths
:
%{}
}
decoded
=
OpenApiSpex
.
resolve_schema_modules
(
spec
)
|>
Jason
.
encode!
()
|>
Jason
.
decode!
()
assert
hd
(
decoded
[
"x-tagGroups"
])[
"name"
]
==
"Methods"
assert
hd
(
decoded
[
"x-tagGroups"
])[
"tags"
]
==
[
"Search"
,
"Fetch"
,
"Delete"
]
assert
is_nil
(
decoded
[
"extensions"
])
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 5:49 AM (2 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38667
Default Alt Text
encode_test.exs (1 KB)
Attached To
Mode
R22 open_api_spex
Attached
Detach File
Event Timeline
Log In to Comment