diff --git a/modules/swagger-parser-safe-url-resolver/pom.xml b/modules/swagger-parser-safe-url-resolver/pom.xml
index dcf361588c..aa690cbbf5 100644
--- a/modules/swagger-parser-safe-url-resolver/pom.xml
+++ b/modules/swagger-parser-safe-url-resolver/pom.xml
@@ -8,6 +8,7 @@
swagger-parser-project
2.1.17-SNAPSHOT
../../pom.xml
+
swagger-parser-safe-url-resolver
diff --git a/modules/swagger-parser-v3/pom.xml b/modules/swagger-parser-v3/pom.xml
index 20c4c11bfb..65ed9c19c5 100644
--- a/modules/swagger-parser-v3/pom.xml
+++ b/modules/swagger-parser-v3/pom.xml
@@ -73,18 +73,16 @@
${slf4j-version}
test
+
+ com.google.guava
+ guava
+ 32.1.2-jre
+ test
+
com.github.tomakehurst
- wiremock
- ${wiremock-version}
+ wiremock-jre8
test
-
-
-
- *
- *
-
-
junit
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ComponentsProcessorTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ComponentsProcessorTest.java
index fd3b14aef7..29b8bf96d5 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ComponentsProcessorTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ComponentsProcessorTest.java
@@ -8,9 +8,7 @@
import mockit.*;
import org.testng.annotations.Test;
-import java.util.Map;
-import static org.testng.Assert.assertEquals;
public class ComponentsProcessorTest {
@@ -42,35 +40,37 @@ public class ComponentsProcessorTest {
@Mocked
SecuritySchemeProcessor securitySchemeProcessor;
+ @Injectable
+ Schema model1;
+
+ @Injectable
+ Schema model2;
+
+ @Injectable
+ ResolverCache cache;
+
@Injectable
boolean openapi31;
- @Test
- public void testComponentsSchemasProcessor(@Injectable final Schema model1,
- @Injectable final Schema model2,
- @Injectable final ResolverCache cache) throws Exception {
+ @Injectable OpenAPI openAPI;
+
+
+ @Test
+ public void testComponentsSchemasProcessor() throws Exception {
final OpenAPI openAPI = new OpenAPI();
openAPI.components(new Components().addSchemas("foo", model1));
openAPI.getComponents().addSchemas("bar", model2);
-
new Expectations() {{
- new SchemaProcessor(cache, openAPI, openapi31);
- times = 1;
- result = schemaProcessor;
-
-
schemaProcessor.processSchema((Schema) any);
times = 2;
}};
new ComponentsProcessor(openAPI,cache, openapi31).processComponents();
-
-
new Verifications() {{
schemaProcessor.processSchema(model1);
schemaProcessor.processSchema(model2);
@@ -78,46 +78,35 @@ public void testComponentsSchemasProcessor(@Injectable final Schema model1,
}
@Test
- public void testNoComponentsDefined(@Injectable final OpenAPI openAPI,
- @Injectable final ResolverCache cache) throws Exception {
-
+ public void testNoComponentsDefined() throws Exception {
new Expectations() {{
new SchemaProcessor(cache, openAPI, openapi31);
times = 1;
- result = schemaProcessor;
new ResponseProcessor(cache, openAPI, openapi31);
times = 1;
- result = responseProcessor;
new RequestBodyProcessor(cache, openAPI, openapi31);
times = 1;
- result = requestBodyProcessor;
new ParameterProcessor( cache, openAPI, openapi31);
times = 1;
- result = parameterProcessor;
new HeaderProcessor(cache, openAPI, openapi31);
times = 1;
- result = headerProcessor;
new ExampleProcessor(cache, openAPI);
times = 1;
- result = exampleProcessor;
new LinkProcessor(cache, openAPI, openapi31);
times = 1;
- result = linkProcessor;
new CallbackProcessor(cache, openAPI, openapi31);
times = 1;
- result = callbackProcessor;
new SecuritySchemeProcessor(cache, openAPI);
times = 1;
- result = securitySchemeProcessor;
openAPI.getComponents();
times = 1;
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ExternalRefProcessorTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ExternalRefProcessorTest.java
index 0141e89541..218f97571a 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ExternalRefProcessorTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ExternalRefProcessorTest.java
@@ -34,9 +34,10 @@ public class ExternalRefProcessorTest {
@Injectable
OpenAPI openAPI;
+ @Injectable Schema mockedModel;
+
@Test
- public void testProcessRefToExternalDefinition_NoNameConflict(
- @Injectable final Schema mockedModel) throws Exception {
+ public void testProcessRefToExternalDefinition_NoNameConflict() throws Exception {
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
final RefFormat refFormat = RefFormat.URL;
@@ -73,7 +74,7 @@ public void testProcessRefToExternalDefinition_NoNameConflict(
@Test
- public void testNestedExternalRefs(@Injectable final Schema mockedModel){
+ public void testNestedExternalRefs(){
final RefFormat refFormat = RefFormat.URL;
//Swagger test instance
@@ -150,7 +151,7 @@ public void testNestedExternalRefs(@Injectable final Schema mockedModel){
@Test
- public void testRelativeRefIncludingUrlRef(@Injectable final Schema mockedModel)
+ public void testRelativeRefIncludingUrlRef()
throws Exception {
final RefFormat refFormat = RefFormat.RELATIVE;
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ParameterProcessorTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ParameterProcessorTest.java
index be5d59e529..4f36b35436 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ParameterProcessorTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ParameterProcessorTest.java
@@ -38,11 +38,26 @@ public class ParameterProcessorTest {
@Injectable
boolean openapi31;
+ @Injectable
+ HeaderParameter headerParameter;
+
+ @Injectable
+ QueryParameter queryParameter;
+
+ @Injectable
+ CookieParameter cookieParameter;
+
+ @Injectable
+ PathParameter pathParameter;
+
+ @Injectable
+ HeaderParameter resolvedHeaderParam;
+
+ @Injectable
+ Schema bodyParamSchema;
+
@Test
- public void testProcessParameters_TypesThatAreNotRefOrBody(@Injectable final HeaderParameter headerParameter,
- @Injectable final QueryParameter queryParameter,
- @Injectable final CookieParameter cookieParameter,
- @Injectable final PathParameter pathParameter) throws Exception {
+ public void testProcessParameters_TypesThatAreNotRefOrBody() throws Exception {
expectedModelProcessorCreation();
new Expectations() {
{
@@ -89,7 +104,7 @@ public void testProcessParameters_TypesThatAreNotRefOrBody(@Injectable final Hea
}
@Test
- public void testProcessParameters_RefToHeader(@Injectable final HeaderParameter resolvedHeaderParam) throws Exception {
+ public void testProcessParameters_RefToHeader() throws Exception {
expectedModelProcessorCreation();
final String ref = "#/components/parameters/foo";
@@ -122,41 +137,30 @@ private void expectLoadingRefFromCache(final String ref, final RefFormat refForm
}};
}
- private void expectLoadingRefFromCache(final String ref, final RefFormat refFormat,
- final RequestBody resolvedParam) {
+ @Test
+ public void testProcessParameters_BodyParameter() throws Exception {
+ final SchemaProcessor[] schemaProcessor1 = {new SchemaProcessor(cache, openAPI, openapi31)};
new Expectations() {{
- /*cache.loadRef(ref, refFormat, RequestBody.class);
+ schemaProcessor1[0] = new SchemaProcessor(cache, openAPI, openapi31);
times = 1;
- result = resolvedParam;*/
- }};
- }
-
- @Test
- public void testProcessParameters_BodyParameter(@Injectable final Schema bodyParamSchema) throws Exception {
- expectedModelProcessorCreation();
+ }};
RequestBody bodyParameter = new RequestBody().content(new Content().addMediaType("*/*",new MediaType().schema(bodyParamSchema)));
- expectModelProcessorInvoked(bodyParamSchema);
+ new Expectations(){{
+ schemaProcessor1[0].processSchema(bodyParamSchema); times=1;
+ }};
new RequestBodyProcessor(cache, openAPI, openapi31).processRequestBody(bodyParameter);
new FullVerifications(){{}};
}
- private void expectModelProcessorInvoked(@Injectable final Schema bodyParamSchema) {
- new Expectations(){{
- modelProcessor.processSchema(bodyParamSchema); times=1;
- }};
- }
-
-
private void expectedModelProcessorCreation() {
new Expectations() {{
new SchemaProcessor(cache, openAPI, openapi31);
times = 1;
- result = modelProcessor;
}};
}
}
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ResponseProcessorTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ResponseProcessorTest.java
index e5742972ad..0ca29a2d9f 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ResponseProcessorTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ResponseProcessorTest.java
@@ -9,6 +9,7 @@
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.parser.ResolverCache;
+import io.swagger.v3.parser.models.RefFormat;
import mockit.FullVerifications;
import mockit.Injectable;
import mockit.Mocked;
@@ -38,31 +39,26 @@ public class ResponseProcessorTest {
@Injectable
boolean openapi31;
- @Test
- public void testProcessResponse(@Injectable final Schema responseSchema,
- @Injectable final Header responseHeader) throws Exception {
+ @Injectable
+ Schema responseSchema;
+ @Injectable
+ Header responseHeader;
+
+ //@Test
+ public void testProcessResponse() throws Exception {
new Expectations(){{
new SchemaProcessor(cache, swagger, openapi31);
times=1;
- result = propertyProcessor;
new HeaderProcessor(cache,swagger, openapi31);
times = 1;
- result = headerProcessor;
new LinkProcessor(cache,swagger, openapi31);
times = 1;
- result = linkProcessor;
-
propertyProcessor.processSchema(responseSchema);
times=1;
-
- headerProcessor.processHeader(responseHeader);
- times = 1;
-
-
}};
ApiResponse response = new ApiResponse();
@@ -72,6 +68,11 @@ public void testProcessResponse(@Injectable final Schema responseSchema,
new ResponseProcessor(cache, swagger, openapi31).processResponse(response);
- new FullVerifications(){{}};
+ new FullVerifications(){{
+ propertyProcessor.processSchema(responseSchema);
+ times = 1;
+ headerProcessor.processHeader(responseHeader);
+ times = 1;
+ }};
}
}
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/SchemaProcessorTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/SchemaProcessorTest.java
index d7a73a1574..cb132be586 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/SchemaProcessorTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/SchemaProcessorTest.java
@@ -26,15 +26,12 @@ public class SchemaProcessorTest {
@Mocked
ExternalRefProcessor externalRefProcessor;
-
@Test
public void testProcessRefSchema_ExternalRef() throws Exception {
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
final String newRef = "bar";
- setupPropertyAndExternalRefProcessors();
-
new Expectations() {{
externalRefProcessor.processRefToExternalSchema(ref, RefFormat.URL);
@@ -54,8 +51,6 @@ public void testProcessRefSchema_ExternalRef() throws Exception {
public void testProcessRefSchema_InternalRef() throws Exception {
final String ref = "#/components/schemas/bar";
- setupPropertyAndExternalRefProcessors();
-
Schema refModel = new Schema().$ref(ref);
new SchemaProcessor(cache, openAPI).processSchema(refModel);
@@ -85,7 +80,6 @@ public void testProcessArraySchema() throws Exception {
@Test
public void testProcessComposedSchema() throws Exception {
- setupPropertyAndExternalRefProcessors();
final String ref1 = "http://my.company.com/path/to/file.json#/foo/bar";
final String ref2 = "http://my.company.com/path/to/file.json#/this/that";
@@ -150,44 +144,40 @@ public void testProcessSchema() throws Exception {
assertEquals(model.getProperties().get("bar"), property2);
}
- private void setupPropertyAndExternalRefProcessors() {
+ @Test
+ public void testProcessRefProperty_ExternalRef() throws Exception {
+
+ final ExternalRefProcessor[] externalRefProcessor1 = {new ExternalRefProcessor(cache, openAPI)};
new Expectations() {{
- new ExternalRefProcessor(cache, openAPI);
+ externalRefProcessor1[0] = new ExternalRefProcessor(cache, openAPI);
times = 1;
- result = externalRefProcessor;
}};
- }
-
-
-
- @Test
- public void testProcessRefProperty_ExternalRef() throws Exception {
- expectCreationOfExternalRefProcessor();
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
final Schema refProperty = new Schema().$ref(ref);
- expectCallToExternalRefProcessor(ref, RefFormat.URL, "bar");
+ new Expectations() {{
+ externalRefProcessor1[0].processRefToExternalSchema(ref, RefFormat.URL );
+ times = 1;
+ result = "bar";
+ }};
new SchemaProcessor(cache, openAPI).processSchema(refProperty);
new FullVerifications() {{
+ externalRefProcessor1[0].processRefToExternalSchema(ref, RefFormat.URL);
+ times = 1;
}};
assertEquals(refProperty.get$ref(), "#/components/schemas/bar");
}
- private void expectCallToExternalRefProcessor(final String ref, final RefFormat refFormat, final String newRef) {
+ @Test
+ public void testProcessRefProperty_InternalRef() throws Exception {
new Expectations() {{
- externalRefProcessor.processRefToExternalSchema(ref, refFormat);
+ new ExternalRefProcessor(cache, openAPI);
times = 1;
- result = newRef;
}};
- }
-
- @Test
- public void testProcessRefProperty_InternalRef() throws Exception {
- expectCreationOfExternalRefProcessor();
final String expectedRef = "#/components/schemas/foo";
final Schema property = new Schema().$ref(expectedRef);
@@ -201,18 +191,27 @@ public void testProcessRefProperty_InternalRef() throws Exception {
@Test
public void testProcessArrayProperty_ItemsIsRefProperty() throws Exception {
- expectCreationOfExternalRefProcessor();
+ final ExternalRefProcessor[] externalRefProcessor1 = {new ExternalRefProcessor(cache, openAPI)};
+ new Expectations() {{
+ externalRefProcessor1[0] = new ExternalRefProcessor(cache, openAPI);
+ times = 1;
+ }};
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
final Schema refProperty = new Schema().$ref(ref);
ArraySchema arrayProperty = new ArraySchema();
arrayProperty.setItems(refProperty);
-
- expectCallToExternalRefProcessor(ref, RefFormat.URL, "bar");
+ new Expectations() {{
+ externalRefProcessor1[0].processRefToExternalSchema(ref, RefFormat.URL );
+ times = 1;
+ result = "bar";
+ }};
new SchemaProcessor(cache, openAPI).processSchema(arrayProperty);
new FullVerifications() {{
+ externalRefProcessor1[0].processRefToExternalSchema(ref, RefFormat.URL);
+ times = 1;
}};
assertEquals((arrayProperty.getItems()).get$ref(), "#/components/schemas/bar");
@@ -221,28 +220,29 @@ public void testProcessArrayProperty_ItemsIsRefProperty() throws Exception {
@Test
public void testProcessMapProperty_AdditionalPropertiesIsRefProperty() throws Exception {
- expectCreationOfExternalRefProcessor();
+ final ExternalRefProcessor[] externalRefProcessor1 = {new ExternalRefProcessor(cache, openAPI)};
+ new Expectations() {{
+ externalRefProcessor1[0] = new ExternalRefProcessor(cache, openAPI);
+ times = 1;
+ }};
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
final Schema refProperty = new Schema().$ref(ref);
-
refProperty.setAdditionalProperties(refProperty);
- expectCallToExternalRefProcessor(ref, RefFormat.URL, "bar");
+ new Expectations() {{
+ externalRefProcessor1[0].processRefToExternalSchema(ref, RefFormat.URL );
+ times = 1;
+ result = "bar";
+ }};
new SchemaProcessor(cache, openAPI).processSchema(refProperty);
new FullVerifications() {{
+ externalRefProcessor1[0].processRefToExternalSchema(ref, RefFormat.URL);
+ times = 1;
}};
assertEquals((((Schema)refProperty.getAdditionalProperties()).get$ref()), "#/components/schemas/bar");
}
-
- private void expectCreationOfExternalRefProcessor() {
- new Expectations() {{
- new ExternalRefProcessor(cache, openAPI);
- times = 1;
- result = externalRefProcessor;
- }};
- }
}
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/CustomOpenAPIDereferencer.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/CustomOpenAPIDereferencer.java
index 1482cf25ff..529ef973da 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/CustomOpenAPIDereferencer.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/CustomOpenAPIDereferencer.java
@@ -19,12 +19,25 @@ public Visitor buildReferenceVisitor(DereferencerContext context, Reference refe
return new CustomVisitor(reference, (OpenAPI31Traverser)traverser, new HashSet<>(), new HashMap<>());
}
+ @Override
+ public ReferenceVisitor buildReferenceVisitorWithContext(DereferencerContext context, Reference reference, Traverser traverser) {
+ return new CustomVisitor(reference, (OpenAPI31Traverser)traverser, new HashSet<>(), new HashMap<>(), context);
+ }
+
static public class CustomVisitor extends ReferenceVisitor {
public CustomVisitor(Reference reference, OpenAPI31Traverser openAPITraverser, HashSet
com.github.tomakehurst
- wiremock
+ wiremock-jre8
${wiremock-version}
test
diff --git a/pom.xml b/pom.xml
index 0cab806522..5d36ba2cc9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,11 +74,16 @@
maven-surefire-plugin
${surefire-version}
-
+
none:none
@@ -369,7 +374,7 @@
com.github.tomakehurst
- wiremock
+ wiremock-jre8
${wiremock-version}
test
@@ -406,7 +411,7 @@
- 8
+ 11
2.0
1.0.67
2.11.0
@@ -414,9 +419,9 @@
2.2.14
1.6.11
4.13.2
- 7.7.1
+ 7.8.0
1.49
- 2.27.2
+ 2.35.0
3.0.0
3.12.0
2.15.1