From 9a01c6e008626a4706a519d9693784b316a4e0c3 Mon Sep 17 00:00:00 2001 From: gracekarina Date: Mon, 13 Nov 2023 11:06:20 -0500 Subject: [PATCH] add constructs to tests --- .../v3/parser/test/OpenAPIV3ParserTest.java | 3 ++ .../failedToResolveExternalRefs.yaml | 2 ++ .../resolve-external-ref/pathItems.yaml | 31 ++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) 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 ed25c77928..8f4141292f 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 @@ -56,6 +56,9 @@ public void testFailedToResolveExternalReferences() { Assert.assertEquals(openAPI.getPaths().get("/permAssignments").getGet().getResponses().get("202").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/schemaResponseSuccess"); Assert.assertTrue(openAPI.getPaths().get("/permAssignmentChangeRequests").get$ref() == null); Assert.assertEquals(openAPI.getPaths().get("/permAssignmentChangeRequests").getGet().getResponses().get("202").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/schemaResponseSuccess"); + Assert.assertTrue(openAPI.getPaths().get("/permAssignmentChange").get$ref() == null); + Assert.assertEquals(openAPI.getPaths().get("/permAssignmentChange").getGet().getResponses().get("201").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/Error"); + Assert.assertEquals(openAPI.getPaths().get("/permAssignmentChange").getGet().getResponses().get("404").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/RemoteError"); } diff --git a/modules/swagger-parser-v3/src/test/resources/resolve-external-ref/failedToResolveExternalRefs.yaml b/modules/swagger-parser-v3/src/test/resources/resolve-external-ref/failedToResolveExternalRefs.yaml index 6bb197c70b..97cf9560a9 100644 --- a/modules/swagger-parser-v3/src/test/resources/resolve-external-ref/failedToResolveExternalRefs.yaml +++ b/modules/swagger-parser-v3/src/test/resources/resolve-external-ref/failedToResolveExternalRefs.yaml @@ -15,6 +15,8 @@ paths: $ref: 'resolve-external-ref/pathItems.yaml#/components/pathitems/permAssignments' /permAssignmentChangeRequests: $ref: 'resolve-external-ref/pathItems.yaml#/components/pathitems/permAssignments' + /permAssignmentChange: + $ref: 'resolve-external-ref/pathItems.yaml#/components/pathitems/permAssignmentChange' components: securitySchemes: diff --git a/modules/swagger-parser-v3/src/test/resources/resolve-external-ref/pathItems.yaml b/modules/swagger-parser-v3/src/test/resources/resolve-external-ref/pathItems.yaml index 380edebb93..15cfbaf167 100644 --- a/modules/swagger-parser-v3/src/test/resources/resolve-external-ref/pathItems.yaml +++ b/modules/swagger-parser-v3/src/test/resources/resolve-external-ref/pathItems.yaml @@ -21,4 +21,33 @@ components: content: application/vnd.api+json: schema: - "$ref": schemas.yaml#/components/schemas/schemaResponseError \ No newline at end of file + "$ref": schemas.yaml#/components/schemas/schemaResponseError + permAssignmentChange: + get: + summary: Permanent Assignment Data Creation + responses: + '201': + description: Accepted + content: + application/vnd.api+json: + schema: + "$ref": "#/components/schemas/Error" + '404': + description: Accepted + content: + application/vnd.api+json: + schema: + "$ref": "#/components/schemas/RemoteError" + schemas: + Error: + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string + RemoteError: + "$ref": schemas.yaml#/components/schemas/schemaResponseError \ No newline at end of file