Skip to content

Commit

Permalink
Rename and improve test for #1565
Browse files Browse the repository at this point in the history
  • Loading branch information
pe-st committed Nov 4, 2023
1 parent 3038032 commit 8924d16
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.smallrye.openapi.runtime.scanner;

import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.io.IOException;

Expand Down Expand Up @@ -44,7 +46,9 @@ void testStreams(String type, Schema.SchemaType itemType, String itemFormat) thr
}

@Test
void testClassWithSchemaTypeString() throws IOException {
void testNoSelfReferencingRegardlessOfScanOrder() throws IOException {
// one way to trigger issue 1565 (self-referencing) was to have a
// non-SchemaType.OBJECT type as a field in another type
@org.eclipse.microprofile.openapi.annotations.media.Schema(
description = "Nested class",
type = SchemaType.STRING)
Expand Down Expand Up @@ -75,8 +79,10 @@ class C {
OpenApiDataObjectScanner.process(contextNFirst, nType);
OpenApiDataObjectScanner.process(contextNFirst, cType);

assertEquals(
contextCFirst.getOpenApi().getComponents().getSchemas().get("1N").getRef(),
contextNFirst.getOpenApi().getComponents().getSchemas().get("1N").getRef());
assertAll("no self referencing"
// the contextCFirst case had "#/components/schemas/1N" from getRef() in smallrye-open-api 3.5.2
, () -> assertNull(contextCFirst.getOpenApi().getComponents().getSchemas().get("1N").getRef(), "C first")
, () -> assertNull(contextNFirst.getOpenApi().getComponents().getSchemas().get("1N").getRef(), "N first")
);
}
}

0 comments on commit 8924d16

Please sign in to comment.