Skip to content

Commit

Permalink
Add missing tests for OpenAPI 3.1 new fields
Browse files Browse the repository at this point in the history
Test that new fields added for OpenAPI 3.1 are read and written
correctly in 3.1 and 3.0 modes.
  • Loading branch information
Azquelt committed Dec 18, 2024
1 parent c8a6a01 commit 3d5dc6b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ void testParseInfo() throws IOException, JSONException {
doTest("info.json", Format.JSON);
}

/**
* Test 3.1 -> 3.0 conversion of info objects
*/
@Test
void testParseInfo30() throws IOException, JSONException {
doMultiVersionTest("info31.json", "info30.json", ConversionDirection.TO_30_ONLY);
doMultiVersionTest("info.json", "info30.json", ConversionDirection.BOTH_WAYS);
}

/**
* Test method for {@link OpenApiParser#parse(java.net.URL)}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,19 @@
}
},
"links": {},
"callbacks": {}
"callbacks": {},
"pathItems": {
"eventNotify": {
"post": {
"description": "Event notification"
}
}
}
},
"webhooks": {
"events": {
"$ref": "#/components/pathItems/eventNotify"
}
},
"x-root-extension-1": "hello world",
"x-root-extension-2": [ true, false ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ components:
in: query
links: {}
callbacks: {}
pathItems:
eventNotify:
post:
description: Event notification
webhooks:
events:
$ref: "#/components/pathItems/eventNotify"
x-root-extension-1: hello world
x-root-extension-2:
- true
Expand Down
18 changes: 18 additions & 0 deletions core/src/test/resources/io/smallrye/openapi/runtime/io/info30.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"openapi" : "3.0.3",
"info" : {
"title": "Sample Pet Store App",
"description": "This is a sample server for a pet store.",
"termsOfService": "http://example.com/terms/",
"contact": {
"name": "API Support",
"url": "http://www.example.com/support",
"email": "[email protected]"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "1.0.1"
}
}
20 changes: 20 additions & 0 deletions core/src/test/resources/io/smallrye/openapi/runtime/io/info31.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"openapi" : "3.1.0",
"info" : {
"title": "Sample Pet Store App",
"description": "This is a sample server for a pet store.",
"summary": "Test sample server",
"termsOfService": "http://example.com/terms/",
"contact": {
"name": "API Support",
"url": "http://www.example.com/support",
"email": "[email protected]"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html",
"identifier": "Apache-2.0"
},
"version": "1.0.1"
}
}

0 comments on commit 3d5dc6b

Please sign in to comment.