From 02a10d9f5c82e99fcc0ac81f7d51c2ad8896e817 Mon Sep 17 00:00:00 2001 From: gracekarina Date: Sat, 17 Aug 2019 12:08:24 -0500 Subject: [PATCH] fix for issue #1169 in 3.0 --- .../v3/parser/util/OpenAPIDeserializer.java | 2 +- .../v3/parser/test/OpenAPIV3ParserTest.java | 10 +++ .../src/test/resources/issue1169.yaml | 83 +++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 modules/swagger-parser-v3/src/test/resources/issue1169.yaml diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java index 259a628163..8582bf87e1 100644 --- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java +++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java @@ -546,7 +546,7 @@ public Paths getPaths(ObjectNode obj, String location, ParseResult result) { } ObjectNode path = (ObjectNode) pathValue; PathItem pathObj = getPathItem(path,String.format("%s.'%s'", location,pathName), result); - String[] eachPart = pathName.split("/"); + String[] eachPart = pathName.split("[-/.]+"); Arrays.stream(eachPart) .filter(part -> part.startsWith("{") && part.endsWith("}") && part.length() > 2) .forEach(part -> { diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java index 5b61b7ebef..13e4fa970c 100644 --- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java +++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java @@ -67,6 +67,16 @@ public class OpenAPIV3ParserTest { protected WireMockServer wireMockServer; + @Test + public void testIssue1169() { + ParseOptions options = new ParseOptions(); + options.setResolve(true); + SwaggerParseResult parseResult = new OpenAPIV3Parser().readLocation("issue1169.yaml", null, options); + assertTrue(parseResult.getMessages().size() == 0); + OpenAPI apispec = parseResult.getOpenAPI(); + assertNotNull(apispec); + } + @Test public void testIssue339() throws Exception { diff --git a/modules/swagger-parser-v3/src/test/resources/issue1169.yaml b/modules/swagger-parser-v3/src/test/resources/issue1169.yaml new file mode 100644 index 0000000000..92031426dd --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/issue1169.yaml @@ -0,0 +1,83 @@ +--- +openapi: 3.0.0 +servers: + - description: Production + url: https://apps.gov.bc.ca/pub/bcgnws + - description: Test + url: https://test.apps.gov.bc.ca/pub/bcgnws + - description: Delivery + url: https://delivery.apps.gov.bc.ca/pub/bcgnws +info: + contact: + email: geographical.names@gov.bc.ca + name: BC Geographical Names Office + url: https://www2.gov.bc.ca/gov/content?id=A3C60F17CE934B1ABFA366F28C66E370 + description: "This REST API provides searchable access to information about geographical + names in the province of British Columbia, including name status and details about + the corresponding geographic feature. \n\nPlease note that you may experience + issues when submitting requests to the delivery or test environment if using this + [OpenAPI specification](https://github.com/bcgov/api-specs) in other API console + viewers." + license: + name: Crown Copyright + url: https://www2.gov.bc.ca/gov/content?id=1AAACC9C65754E4D89A118B875E0FBDA + title: BC Geographical Names Web Service - + version: 3.x.x + x-apisguru-categories: + - open_data + x-logo: + url: https://api.apis.guru/v2/cache/logo/https_avatars1.githubusercontent.com_u_916280.jpeg + x-origin: + - converter: + url: https://github.com/lucybot/api-spec-converter + version: 2.7.31 + format: openapi + url: https://raw.githubusercontent.com/bcgov/api-specs/master/bcgnws/bcgnws.json + version: '3.0' + x-preferred: true + x-providerName: gov.bc.ca + x-serviceName: bcgnws +tags: + - name: search + - name: name + - name: feature + - name: feature taxonomy + - name: name authority +paths: + "/names/{nameId}.{outputFormat}": + get: + description: Get information about the geographical name with the specified + nameId. + parameters: + - description: The unique identifier for a name + example: 22474 + in: path + name: nameId + required: true + schema: + type: integer + - description: The format of the output. + example: json + in: path + name: outputFormat + required: true + schema: + default: json + enum: + - json + - xml + - kml + - csv + - html + type: string + responses: + '200': + description: Information about the name with the specified nameId + '404': + description: The name with the given nameId doesn't exist, or the output + format is invalid. + summary: Get a name by its nameId + tags: + - name +components: + schemas: {} \ No newline at end of file