Repository: quarkusio/quarkus
Issue: OpenAPI: Use standard value for query parameter "format"

As discussed with @EricWittmann on gitter, the MicroProfile specification is clear about the optional query parameter `format` that is used to control the format of the OpenAPI specification:

```
GET http://<host>:<port>/openapi?format=<value>
```

The `<value>` can be:
* `YAML`
* `JSON`

See: https://github.com/eclipse/microprofile-open-api/blob/1.x/spec/src/main/asciidoc/microprofile-openapi-spec.adoc#53-query-parameters

—

The current implementation checks for following values:

* `application/yaml`
* `application/json`

Those are the values expected for the `Accept` header (that can also be used to control the format of the generated OpenAPI)

Changed files:
extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiPathWithoutSegmentsTestCase.java
extensions/smallrye-openapi/runtime/src/main/java/io/quarkus/smallrye/openapi/runtime/OpenApiServlet.java
extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiPathWithSegmentsTestCase.java
extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiDefaultPathTestCase.java

diff --git a/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiDefaultPathTestCase.java b/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiDefaultPathTestCase.java
index eae4a54f953..da5501a9658 100644
--- a/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiDefaultPathTestCase.java
+++ b/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiDefaultPathTestCase.java
@@ -18,9 +18,17 @@ public class OpenApiDefaultPathTestCase {
 
     @Test
     public void testOpenApiPathAccessResource() {
-        RestAssured.given().queryParam("format", "application/yaml").when().get(OPEN_API_PATH).then().header("Content-Type",
-                "application/yaml;charset=UTF-8");
-        RestAssured.given().queryParam("format", "application/json").when().get(OPEN_API_PATH).then().header("Content-Type",
-                "application/json;charset=UTF-8");
+        RestAssured.given().header("Accept", "application/yaml")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/yaml;charset=UTF-8");
+        RestAssured.given().queryParam("format", "YAML")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/yaml;charset=UTF-8");
+        RestAssured.given().header("Accept", "application/json")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/json;charset=UTF-8");
+        RestAssured.given().queryParam("format", "JSON")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/json;charset=UTF-8");
     }
 }
diff --git a/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiPathWithSegmentsTestCase.java b/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiPathWithSegmentsTestCase.java
index b1ec005f240..6be40d3ff73 100644
--- a/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiPathWithSegmentsTestCase.java
+++ b/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiPathWithSegmentsTestCase.java
@@ -21,9 +21,17 @@ public class OpenApiPathWithSegmentsTestCase {
 
     @Test
     public void testOpenApiPathAccessResource() {
-        RestAssured.given().queryParam("format", "application/yaml").when().get(OPEN_API_PATH).then().header("Content-Type",
-                "application/yaml;charset=UTF-8");
-        RestAssured.given().queryParam("format", "application/json").when().get(OPEN_API_PATH).then().header("Content-Type",
-                "application/json;charset=UTF-8");
+        RestAssured.given().header("Accept", "application/yaml")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/yaml;charset=UTF-8");
+        RestAssured.given().queryParam("format", "YAML")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/yaml;charset=UTF-8");
+        RestAssured.given().header("Accept", "application/json")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/json;charset=UTF-8");
+        RestAssured.given().queryParam("format", "JSON")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/json;charset=UTF-8");
     }
 }
diff --git a/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiPathWithoutSegmentsTestCase.java b/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiPathWithoutSegmentsTestCase.java
index 5c2cc02a479..03088b70d02 100644
--- a/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiPathWithoutSegmentsTestCase.java
+++ b/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/OpenApiPathWithoutSegmentsTestCase.java
@@ -21,9 +21,17 @@ public class OpenApiPathWithoutSegmentsTestCase {
 
     @Test
     public void testOpenApiPathAccessResource() {
-        RestAssured.given().queryParam("format", "application/yaml").when().get(OPEN_API_PATH).then().header("Content-Type",
-                "application/yaml;charset=UTF-8");
-        RestAssured.given().queryParam("format", "application/json").when().get(OPEN_API_PATH).then().header("Content-Type",
-                "application/json;charset=UTF-8");
+        RestAssured.given().header("Accept", "application/yaml")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/yaml;charset=UTF-8");
+        RestAssured.given().queryParam("format", "YAML")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/yaml;charset=UTF-8");
+        RestAssured.given().header("Accept", "application/json")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/json;charset=UTF-8");
+        RestAssured.given().queryParam("format", "JSON")
+                .when().get(OPEN_API_PATH)
+                .then().header("Content-Type", "application/json;charset=UTF-8");
     }
 }
diff --git a/extensions/smallrye-openapi/runtime/src/main/java/io/quarkus/smallrye/openapi/runtime/OpenApiServlet.java b/extensions/smallrye-openapi/runtime/src/main/java/io/quarkus/smallrye/openapi/runtime/OpenApiServlet.java
index c5b00379a90..1584f7fd9a5 100644
--- a/extensions/smallrye-openapi/runtime/src/main/java/io/quarkus/smallrye/openapi/runtime/OpenApiServlet.java
+++ b/extensions/smallrye-openapi/runtime/src/main/java/io/quarkus/smallrye/openapi/runtime/OpenApiServlet.java
@@ -39,7 +39,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
 
         // Check Accept, then query parameter "format" for JSON; else use YAML.
         if ((accept != null && accept.contains(OpenApiSerializer.Format.JSON.getMimeType())) ||
-                (OpenApiSerializer.Format.JSON.getMimeType().equalsIgnoreCase(formatParam))) {
+                ("JSON".equalsIgnoreCase(formatParam))) {
             format = OpenApiSerializer.Format.JSON;
         }