From 57f8fc99f5370dc843f52a6488ba26534c520ebf Mon Sep 17 00:00:00 2001 From: Matheus Cruz Date: Thu, 22 Feb 2024 16:42:59 -0300 Subject: [PATCH] Set extension as experimental and handle possible number format error --- .../deployment/wiremock/OpenApi2WiremockMapper.java | 13 +++++++++---- wiremock/docs/modules/ROOT/pages/index.adoc | 2 +- .../src/main/resources/quarkus-extension.yaml | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/wiremock/deployment/src/main/java/io/quarkiverse/openapi/wiremock/generator/deployment/wiremock/OpenApi2WiremockMapper.java b/wiremock/deployment/src/main/java/io/quarkiverse/openapi/wiremock/generator/deployment/wiremock/OpenApi2WiremockMapper.java index e8029691..571c224c 100644 --- a/wiremock/deployment/src/main/java/io/quarkiverse/openapi/wiremock/generator/deployment/wiremock/OpenApi2WiremockMapper.java +++ b/wiremock/deployment/src/main/java/io/quarkiverse/openapi/wiremock/generator/deployment/wiremock/OpenApi2WiremockMapper.java @@ -125,9 +125,9 @@ private static String generateResponseBody(final Schema schema) { /** * This method attempts to retrieve the first status code defined in the {@link Operation} object. - * If the OpenAPI response contains only the "default" status code, this method will return + * Whether the OpenAPI response contains only the "default" status code, this method will return * {@link OpenApi2WiremockMapper#DEFAULT_STATUS_CODE}. - * If the OpenAPI response contains more than one status code, the method returns the first one. + * Whether the OpenAPI response contains more than one status code, the method returns the first one. * For example, if the status codes are "200" and after "400", this method will return the status "200". * * @param operation The {@link Operation} instance from which to extract the status code. @@ -145,10 +145,15 @@ private static int getStatusCode(final Operation operation) { .getKey(); if (statusCode.contentEquals(defaultStatus)) { - return OpenApi2WiremockMapper.DEFAULT_STATUS_CODE; + return DEFAULT_STATUS_CODE; } - return Integer.parseInt(statusCode); + try { + return Integer.parseInt(statusCode); + } catch (NumberFormatException e) { + throw new IllegalArgumentException( + String.format("Was not possible to parse the status code '%s' from OpenAPI Operation", statusCode)); + } } public String getComponentName(final String $ref) { diff --git a/wiremock/docs/modules/ROOT/pages/index.adoc b/wiremock/docs/modules/ROOT/pages/index.adoc index 6fd907e2..206caf65 100644 --- a/wiremock/docs/modules/ROOT/pages/index.adoc +++ b/wiremock/docs/modules/ROOT/pages/index.adoc @@ -1,5 +1,5 @@ = Quarkus - Openapi Generator - Wiremock -:extension-status: preview +:extension-status: experimental WARNING: This is the instructions for the latest SNAPSHOT version (main branch). Please, see the https://docs.quarkiverse.io/quarkus-openapi-generator/dev/index.html[latest **released** documentation] if you are looking for instructions. diff --git a/wiremock/runtime/src/main/resources/quarkus-extension.yaml b/wiremock/runtime/src/main/resources/quarkus-extension.yaml index 45d45226..11749831 100644 --- a/wiremock/runtime/src/main/resources/quarkus-extension.yaml +++ b/wiremock/runtime/src/main/resources/quarkus-extension.yaml @@ -7,4 +7,5 @@ metadata: - "wiremock" categories: - "web" - status: "preview" \ No newline at end of file + status: "experimental" + guide: "https://docs.quarkiverse.io/quarkus-openapi-generator/dev"