From 980a480e311314c38cb6e12fd5f856c3d3630f94 Mon Sep 17 00:00:00 2001 From: Steve Hu Date: Mon, 12 Sep 2022 11:26:52 -0400 Subject: [PATCH] fixes #18 upgrade the initiating OpenApiHelper after multiple specifications support --- pom.xml | 12 ++++++------ .../openapi/validation/OpenApiValidator.java | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 14be920..681fbae 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 4.0.0 com.mservicetech openapi-schema-validation - 2.0.3 + 2.0.4 jar openapi schema for openpai 3.* https://github.com/mservicetech/openapi-schema-validation @@ -57,13 +57,13 @@ 11 UTF-8 1.0.69 - 2.1.1 - 2.12.1 + 2.1.2-SNAPSHOT + 2.13.3 1.26 - 1.7.32 + 1.7.36 3.5 - 1.2.3 - 4.12 + 1.2.11 + 4.13.1 2.7.21 3.1.0 2.4 diff --git a/src/main/java/com/mservicetech/openapi/validation/OpenApiValidator.java b/src/main/java/com/mservicetech/openapi/validation/OpenApiValidator.java index 85ca145..f22d6db 100644 --- a/src/main/java/com/mservicetech/openapi/validation/OpenApiValidator.java +++ b/src/main/java/com/mservicetech/openapi/validation/OpenApiValidator.java @@ -61,7 +61,7 @@ public OpenApiValidator() { } } spec = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n")); - openApiHelper = OpenApiHelper.init(spec); + openApiHelper = new OpenApiHelper(spec); schemaValidator = new SchemaValidator(openApiHelper.openApi3); } catch (Exception e) { logger.error("initial failed:" + e); @@ -76,7 +76,7 @@ public OpenApiValidator() { public OpenApiValidator(String openapiPath) { InputStream in = this.getClass().getClassLoader().getResourceAsStream(openapiPath); spec = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n")); - openApiHelper = OpenApiHelper.init(spec); + openApiHelper = new OpenApiHelper(spec); schemaValidator = new SchemaValidator(openApiHelper.openApi3); } @@ -87,7 +87,7 @@ public OpenApiValidator(String openapiPath) { */ public OpenApiValidator(InputStream openapi) { spec = new BufferedReader(new InputStreamReader(openapi, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n")); - openApiHelper = OpenApiHelper.init(spec); + openApiHelper = new OpenApiHelper(spec); schemaValidator = new SchemaValidator(openApiHelper.openApi3); } @@ -100,7 +100,7 @@ public OpenApiValidator(InputStream openapi) { */ public Status validateRequestPath (String requestURI , String httpMethod, RequestEntity requestEntity ) { requireNonNull(openApiHelper, "openApiHelper object cannot be null"); - final NormalisedPath requestPath = new ApiNormalisedPath(requestURI); + final NormalisedPath requestPath = new ApiNormalisedPath(requestURI, openApiHelper.basePath); final Optional maybeApiPath = openApiHelper.findMatchingApiPath(requestPath); if (!maybeApiPath.isPresent()) { Status status = new Status( STATUS_INVALID_REQUEST_PATH, requestPath.normalised());