eclipse / microprofile-open-api

Microprofile open api
Apache License 2.0
131 stars 81 forks source link

Add comprehensive annotation extension tests #537

Closed Azquelt closed 2 years ago

Azquelt commented 2 years ago

Make sure the TCK exercises the extensions attribute on every annotation which has one.

To write the tests, I had to make changes to the annotations on JAXRSApp which had been mangled by the formatter, so as a prerequisite step I added a tweak to the standard microprofile formatting rules and reformatted the code. The update and reformatting are done in separate commits.

For #387

Azquelt commented 2 years ago

I've put this in draft for the moment as smallrye-open-api isn't producing some of the extensions correctly yet so I can't verify that I've written the assertions correctly.

Azquelt commented 2 years ago

I now have these passing under Smallrye OpenAPI

Azquelt commented 2 years ago

As I went to merge this, I spotted that I'd squashed my last typo changes into the wrong commit and they hadn't been included in this PR, I've just updated it to include them and re-run the tests against smallrye.

Fixes are:

@@ -100,7 +100,7 @@ public class AirlinesAppTest extends AppTestBase {
         ValidatableResponse vr = callEndpoint(type);
         vr.body("externalDocs.description", equalTo("instructions for how to deploy this app"));
         vr.body("externalDocs.url", containsString("README.md"));
-        vr.body("externalDocs.x-external-docs", equalTo("text-external-docs"));
+        vr.body("externalDocs.x-external-docs", equalTo("test-external-docs"));
     }

     @RunAsClient
@@ -434,7 +434,7 @@ public class AirlinesAppTest extends AppTestBase {
         vr.body(availabilityParameters + ".findAll { it.name == 'numberOfChildren' }.schema.minimum",
                 both(hasSize(1)).and(contains(0)));
         vr.body(availabilityParameters + ".findAll { it.name == 'airportFrom' }.x-parameter",
-                equalTo("test-parameter"));
+                contains("test-parameter"));

         vr.body(availabilityParameters + ".findAll { it.$ref == '#/components/parameters/departureDate'}",
                 notNullValue());
@@ -462,7 +462,7 @@ public class AirlinesAppTest extends AppTestBase {
         endpoint = "paths.'/reviews'.post.callbacks";
         vr.body(endpoint, hasKey("testCallback"));
         vr.body(endpoint + ".testCallback", hasKey("http://localhost:9080/oas3-airlines/reviews"));
-        vr.body(endpoint + "testCallback.x-callback", equalTo("test-callback"));
+        vr.body(endpoint + ".testCallback.x-callback", equalTo("test-callback"));

         endpoint = "paths.'/bookings'.post.callbacks";
         vr.body(endpoint, hasKey("bookingCallback"));