Skip to content

Commit

Permalink
Add failing test about resolving path-items
Browse files Browse the repository at this point in the history
  • Loading branch information
ahx committed Dec 19, 2024
1 parent 2a239b6 commit 18b707f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/open_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,45 @@ def test_access_mode
assert(schemer.valid?({ 'write_only_true' => 2 }, :access_mode => 'write'))
end

def test_path_item_ref
openapi = {
'openapi' => '3.1.0',
'info' => {
'title' => 'Example $refs on every level',
'version' => '1.0.0'
},
'paths' => {
'/stations' => {
'$ref' => '#/components/pathItems/stations'
}
},
'components' => {
'pathItems' => {
'stations' => {
'get' => {
'responses' => {
'200' => {
'description' => 'OK',
'content' => {
'application/json' => {
'schema' => {
'type' => 'object'
}
}
},
}
}
}
},
},
}}

document = JSONSchemer.openapi(openapi)
pointer = '#/paths/~1stations/get/responses/200/content/application~1json/schema'
assert(document.ref(pointer).valid?({}))
refute(document.ref(pointer).valid?(2))
end

def test_nullable
schemer = JSONSchemer.openapi({
'openapi' => '3.0.0',
Expand Down

0 comments on commit 18b707f

Please sign in to comment.