Skip to content

Commit

Permalink
Implement a test for swagger-api#1961
Browse files Browse the repository at this point in the history
  • Loading branch information
AmateurECE committed Nov 9, 2023
1 parent c690d8d commit 4c79270
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import io.swagger.v3.parser.OpenAPIV3Parser;
import io.swagger.v3.parser.core.models.ParseOptions;
import io.swagger.v3.parser.core.models.SwaggerParseResult;
import org.testng.annotations.Test;

import static org.testng.Assert.assertFalse;

public class ResolverCacheTestCircular {
@Test
public void testIssue1961_DuplicateSchemas_ABA() {
ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolve(true);
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("src/test/resources/issue-1961/Foo.yaml", null, parseOptions);
assertFalse(result.getOpenAPI().getComponents().getSchemas().containsKey("TestCase_1"));
}
}
13 changes: 13 additions & 0 deletions modules/swagger-parser-v3/src/test/resources/issue-1961/Bar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
components:
schemas:
Bar:
anyOf:
- $ref: ./Foo.yaml#/components/schemas/FooBar
BarType:
enum:
- All
- OEM
type: string
info:
title: '#Issue1961.Bar'
openapi: 3.0.1
17 changes: 17 additions & 0 deletions modules/swagger-parser-v3/src/test/resources/issue-1961/Foo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
components:
schemas:
FooBar:
properties:
BypassTypes:
items:
$ref: ./Bar.yaml#/components/schemas/BarType
type: array
type: object
Foo:
properties:
MFABypass:
$ref: ./Bar.yaml#/components/schemas/Bar
type: object
info:
title: '#Issue1961.Foo'
openapi: 3.0.1

0 comments on commit 4c79270

Please sign in to comment.