diff --git a/.github/workflows/maven-pulls.yml b/.github/workflows/maven-pulls.yml
index 96975e8438..4328767c1d 100644
--- a/.github/workflows/maven-pulls.yml
+++ b/.github/workflows/maven-pulls.yml
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- java: [ 8, 11, 14 ]
+ java: [ 11, 14, 17 ]
steps:
- uses: actions/checkout@v2
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 642d1020c6..7f95213eda 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- java: [ 8, 11, 14 ]
+ java: [ 11, 14, 17 ]
steps:
- uses: actions/checkout@v2
@@ -38,7 +38,7 @@ jobs:
mvn --no-transfer-progress -B install --file pom.xml
export MY_JAVA_VERSION=`java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1`
echo "JAVA VERSION" ${MY_JAVA_VERSION}
- if [[ ${MY_JAVA_VERSION} == "8" ]];
+ if [[ ${MY_JAVA_VERSION} == "11" ]];
then
export MY_POM_VERSION=`mvn -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
diff --git a/.github/workflows/next-snapshot.yml b/.github/workflows/next-snapshot.yml
index b712ab8422..113fb429d8 100644
--- a/.github/workflows/next-snapshot.yml
+++ b/.github/workflows/next-snapshot.yml
@@ -20,10 +20,10 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 2.7
- - name: Set up Java 8
+ - name: Set up Java 11
uses: actions/setup-java@v2
with:
- java-version: 8
+ java-version: 11
distribution: 'zulu'
server-id: ossrh
server-username: MAVEN_USERNAME
diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml
index b8f7da9afd..01f6a92b16 100644
--- a/.github/workflows/prepare-release.yml
+++ b/.github/workflows/prepare-release.yml
@@ -20,10 +20,10 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 2.7
- - name: Set up Java 8
+ - name: Set up Java 11
uses: actions/setup-java@v2
with:
- java-version: 8
+ java-version: 11
distribution: 'zulu'
server-id: ossrh
server-username: MAVEN_USERNAME
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e1bafb9d8b..186b096ce0 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -20,10 +20,10 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 2.7
- - name: Set up Java 8
+ - name: Set up Java 11
uses: actions/setup-java@v2
with:
- java-version: 8
+ java-version: 11
distribution: 'zulu'
server-id: ossrh
server-username: MAVEN_USERNAME
diff --git a/README.md b/README.md
index 74e60a9288..73a8637983 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
**NOTE:** Since version 2.1.0 Swagger Parser supports OpenAPI 3.1; see [this page](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---OpenAPI-3.1) for details
-
+
# Table of contents
@@ -121,7 +121,7 @@ You can include this library from Sonatype OSS for SNAPSHOTS, or Maven central f
#### Prerequisites
You need the following installed and available in your $PATH:
-* [Java 1.8](http://java.oracle.com)
+* Java 11
* [Apache maven 3.x](http://maven.apache.org/)
After cloning the project, you can build it from source with this command:
diff --git a/modules/swagger-parser-cli/pom.xml b/modules/swagger-parser-cli/pom.xml
index 2f3557bdb1..e18c2396fa 100644
--- a/modules/swagger-parser-cli/pom.xml
+++ b/modules/swagger-parser-cli/pom.xml
@@ -26,6 +26,28 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${surefire-version}
+
+ none:none
+ -javaagent:"${settings.localRepository}"/org/jmockit/jmockit/${jmockit-version}/jmockit-${jmockit-version}.jar --add-opens java.base/java.lang=ALL-UNNAMED -Djdk.attach.allowAttachSelf
+
+
+
+ test-testng
+ test
+
+ test
+
+
+ none:none
+ org.testng:testng
+
+
+
+
org.apache.maven.plugins
maven-jar-plugin
@@ -40,7 +62,7 @@
org.apache.maven.plugins
maven-shade-plugin
- 2.3
+ 3.3.0
process-resources
@@ -73,8 +95,10 @@
compile
- org.testng
- testng
+ junit
+ junit
+ ${junit-version}
+ test
net.sourceforge.argparse4j
@@ -84,13 +108,16 @@
org.slf4j
slf4j-simple
- 2.0.0
+ ${slf4j-version}
+ test
+
+
+ org.testng
+ testng
+ ${testng-version}
+ test
-
- 8
- 8
-
-
\ No newline at end of file
+
diff --git a/modules/swagger-parser-v2-converter/pom.xml b/modules/swagger-parser-v2-converter/pom.xml
index e364e2a6ab..0e0e57acfc 100644
--- a/modules/swagger-parser-v2-converter/pom.xml
+++ b/modules/swagger-parser-v2-converter/pom.xml
@@ -10,7 +10,32 @@
swagger-parser-v2-converter
jar
swagger-parser-v2-converter
-
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${surefire-version}
+
+ none:none
+ -javaagent:"${settings.localRepository}"/org/jmockit/jmockit/${jmockit-version}/jmockit-${jmockit-version}.jar --add-opens java.base/java.lang=ALL-UNNAMED -Djdk.attach.allowAttachSelf
+
+
+
+ test-testng
+ test
+
+ test
+
+
+ none:none
+ org.testng:testng
+
+
+
+
+
+
io.swagger
@@ -75,7 +100,13 @@
org.testng
testng
- 6.9.10
+ ${testng-version}
+ test
+
+
+ junit
+ junit
+ ${junit-version}
test
diff --git a/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java b/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java
index cc5912ae17..41425bca06 100644
--- a/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java
+++ b/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java
@@ -1,6 +1,5 @@
package io.swagger.parser.test;
-import io.swagger.util.Yaml;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
diff --git a/modules/swagger-parser-v3/pom.xml b/modules/swagger-parser-v3/pom.xml
index 51216143bc..35622199ef 100644
--- a/modules/swagger-parser-v3/pom.xml
+++ b/modules/swagger-parser-v3/pom.xml
@@ -10,8 +10,6 @@
swagger-parser-v3
jar
swagger-parser-v3
-
-
io.swagger.core.v3
@@ -61,7 +59,7 @@
org.testng
testng
- 6.9.10
+ ${testng-version}
test
@@ -73,10 +71,9 @@
com.github.tomakehurst
wiremock
- 1.57
+ ${wiremock-version}
test
- standalone
*
@@ -87,6 +84,8 @@
junit
junit
+ ${junit-version}
+ test
diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/DeserializationUtils.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/DeserializationUtils.java
index 7799d93fa0..18580b4836 100644
--- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/DeserializationUtils.java
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/DeserializationUtils.java
@@ -194,13 +194,26 @@ public static boolean isJson(String contents) {
return contents.toString().trim().startsWith("{");
}
+ public static LoaderOptions buildLoaderOptions() {
+ LoaderOptions loaderOptions = new LoaderOptions();
+ try {
+ Method method = LoaderOptions.class.getMethod("setMaxAliasesForCollections", int.class);
+ method.invoke(loaderOptions, options.getMaxYamlAliasesForCollections());
+ method = LoaderOptions.class.getMethod("setAllowRecursiveKeys", boolean.class);
+ method.invoke(loaderOptions, options.isYamlAllowRecursiveKeys());
+ } catch (ReflectiveOperationException e) {
+ LOGGER.debug("using snakeyaml < 1.25, not setting YAML Billion Laughs Attack snakeyaml level protection");
+ }
+ return loaderOptions;
+ }
+
public static JsonNode readYamlTree(String contents) {
return readYamlTree(contents, null, new SwaggerParseResult());
}
public static JsonNode readYamlTree(String contents, ParseOptions parseOptions, SwaggerParseResult deserializationUtilsResult) {
if (parseOptions != null && parseOptions.isLegacyYamlDeserialization()) {
- org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor());
+ org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor(buildLoaderOptions()));
return Json.mapper().convertValue(yaml.load(contents), JsonNode.class);
}
try {
@@ -208,7 +221,7 @@ public static JsonNode readYamlTree(String contents, ParseOptions parseOptions,
if (options.isValidateYamlInput()) {
yaml = buildSnakeYaml(new CustomSnakeYamlConstructor());
} else {
- yaml = buildSnakeYaml(new SafeConstructor());
+ yaml = buildSnakeYaml(new SafeConstructor(buildLoaderOptions()));
}
Object o = yaml.load(contents);
if (options.isValidateYamlInput()) {
@@ -244,7 +257,7 @@ public static T readYamlValue(String contents, Class expectedType) {
return readYamlValue(contents, expectedType, false);
}
public static T readYamlValue(String contents, Class expectedType, boolean openapi31) {
- org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor());
+ org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor(buildLoaderOptions()));
ObjectMapper jsonMapper = openapi31 ? Json31.mapper() : Json.mapper();
return jsonMapper.convertValue(yaml.load(contents), expectedType);
}
@@ -256,20 +269,12 @@ public static org.yaml.snakeyaml.Yaml buildSnakeYaml(BaseConstructor constructor
return new org.yaml.snakeyaml.Yaml(constructor);
}
try {
- LoaderOptions loaderOptions = new LoaderOptions();
- Method method = LoaderOptions.class.getMethod("setMaxAliasesForCollections", int.class);
- method.invoke(loaderOptions, options.getMaxYamlAliasesForCollections());
- method = LoaderOptions.class.getMethod("setAllowRecursiveKeys", boolean.class);
- method.invoke(loaderOptions, options.isYamlAllowRecursiveKeys());
- method = LoaderOptions.class.getMethod("setAllowDuplicateKeys", boolean.class);
- method.invoke(loaderOptions, false);
- method = LoaderOptions.class.getMethod("setCodePointLimit", int.class);
- method.invoke(loaderOptions, options.getMaxYamlCodePoints());
- org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(constructor, new Representer(), new DumperOptions(), loaderOptions, new CustomResolver());
+ LoaderOptions loaderOptions = buildLoaderOptions();
+ org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(constructor, new Representer(new DumperOptions()), new DumperOptions(), loaderOptions, new CustomResolver());
return yaml;
- } catch (ReflectiveOperationException e) {
+ } catch (Exception e) {
//
- LOGGER.debug("using snakeyaml < 1.25, not setting YAML Billion Laughs Attack snakeyaml level protection");
+ LOGGER.error("error building snakeYaml", e);
}
return new org.yaml.snakeyaml.Yaml(constructor);
}
@@ -396,6 +401,10 @@ public SnakeException(String message, Throwable cause) {
static class CustomSnakeYamlConstructor extends SafeConstructor {
+ public CustomSnakeYamlConstructor() {
+ super(buildLoaderOptions());
+ }
+
private boolean checkNode(MappingNode node, Integer depth) {
if (node.getValue() == null) return true;
if (depth > options.getMaxYamlDepth()) return false;
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 9d125dba1c..fd3b14aef7 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
@@ -82,7 +82,7 @@ public void testNoComponentsDefined(@Injectable final OpenAPI openAPI,
@Injectable final ResolverCache cache) throws Exception {
- new StrictExpectations() {{
+ new Expectations() {{
new SchemaProcessor(cache, openAPI, openapi31);
times = 1;
result = schemaProcessor;
@@ -131,79 +131,4 @@ public void testNoComponentsDefined(@Injectable final OpenAPI openAPI,
new FullVerifications() {{
}};
}
-
- @Test
- public void testDefinitionsProcessor_RefModelInDefinitionsMap(@Injectable final Schema resolvedModel) throws Exception {
- final OpenAPI openAPI = new OpenAPI();
- final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
- final Schema refModel = new Schema().$ref(ref);
- openAPI.components(new Components().addSchemas("foo", refModel));
-
- final MockUp mockup = new MockUp() {
- @Mock
- String getRenamedRef(String ref) {
- openAPI.getComponents().getSchemas().put("bar", resolvedModel);
- return "bar";
- }
- };
-
- final ResolverCache mockResolverCache = mockup.getMockInstance();
-
-
- new StrictExpectations() {{
-
- new SchemaProcessor(mockResolverCache, openAPI, openapi31);
- times = 1;
- result = schemaProcessor;
-
- new ResponseProcessor(mockResolverCache, openAPI, openapi31);
- times = 1;
- result = responseProcessor;
-
- new RequestBodyProcessor(mockResolverCache, openAPI, openapi31);
- times = 1;
- result = requestBodyProcessor;
-
- new ParameterProcessor( mockResolverCache, openAPI, openapi31);
- times = 1;
- result = parameterProcessor;
-
- new HeaderProcessor(mockResolverCache, openAPI, openapi31);
- times = 1;
- result = headerProcessor;
-
- new ExampleProcessor(mockResolverCache, openAPI);
- times = 1;
- result = exampleProcessor;
-
- new LinkProcessor(mockResolverCache, openAPI, openapi31);
- times = 1;
- result = linkProcessor;
-
- new CallbackProcessor(mockResolverCache, openAPI, openapi31);
- times = 1;
- result = callbackProcessor;
-
- new SecuritySchemeProcessor(mockResolverCache, openAPI);
- times = 1;
- result = securitySchemeProcessor;
-
- schemaProcessor.processSchema(refModel);
- times = 1;
-
- resolvedModel.getProperties();
- times = 1;
-
- }};
-
- new ComponentsProcessor(openAPI, mockResolverCache, openapi31).processComponents();
-
- new FullVerifications(){{}};
-
- final Map definitions = openAPI.getComponents().getSchemas();
- assertEquals(definitions.size(), 1);
-
- final Schema foo = definitions.get("foo");
- assertEquals(foo, resolvedModel);
- }
}
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 3aa60e44cb..0141e89541 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
@@ -12,7 +12,7 @@
import mockit.Expectations;
import mockit.Injectable;
import mockit.Mocked;
-import mockit.StrictExpectations;
+import mockit.Expectations;
import org.testng.annotations.Test;
import java.util.ArrayList;
@@ -41,7 +41,7 @@ public void testProcessRefToExternalDefinition_NoNameConflict(
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
final RefFormat refFormat = RefFormat.URL;
- new StrictExpectations() {{
+ new Expectations() {{
cache.getRenamedRef(ref);
times = 1;
result = null;
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 588e654ddf..be5d59e529 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
@@ -115,7 +115,7 @@ public void testProcessParameters_RefToHeader(@Injectable final HeaderParameter
private void expectLoadingRefFromCache(final String ref, final RefFormat refFormat,
final Parameter resolvedParam) {
- new StrictExpectations() {{
+ new Expectations() {{
cache.loadRef(ref, refFormat, Parameter.class);
times = 1;
result = resolvedParam;
@@ -124,7 +124,7 @@ private void expectLoadingRefFromCache(final String ref, final RefFormat refForm
private void expectLoadingRefFromCache(final String ref, final RefFormat refFormat,
final RequestBody resolvedParam) {
- new StrictExpectations() {{
+ new Expectations() {{
/*cache.loadRef(ref, refFormat, RequestBody.class);
times = 1;
result = resolvedParam;*/
@@ -146,14 +146,14 @@ public void testProcessParameters_BodyParameter(@Injectable final Schema bodyPar
}
private void expectModelProcessorInvoked(@Injectable final Schema bodyParamSchema) {
- new StrictExpectations(){{
+ new Expectations(){{
modelProcessor.processSchema(bodyParamSchema); times=1;
}};
}
private void expectedModelProcessorCreation() {
- new StrictExpectations() {{
+ 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 5d93b0e1d3..e5742972ad 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
@@ -12,7 +12,7 @@
import mockit.FullVerifications;
import mockit.Injectable;
import mockit.Mocked;
-import mockit.StrictExpectations;
+import mockit.Expectations;
import org.testng.annotations.Test;
@@ -42,7 +42,7 @@ public class ResponseProcessorTest {
public void testProcessResponse(@Injectable final Schema responseSchema,
@Injectable final Header responseHeader) throws Exception {
- new StrictExpectations(){{
+ new Expectations(){{
new SchemaProcessor(cache, swagger, openapi31);
times=1;
result = propertyProcessor;
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 28a5fd5e11..d7a73a1574 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
@@ -35,7 +35,7 @@ public void testProcessRefSchema_ExternalRef() throws Exception {
setupPropertyAndExternalRefProcessors();
- new StrictExpectations() {{
+ new Expectations() {{
externalRefProcessor.processRefToExternalSchema(ref, RefFormat.URL);
times = 1;
@@ -151,7 +151,7 @@ public void testProcessSchema() throws Exception {
}
private void setupPropertyAndExternalRefProcessors() {
- new StrictExpectations() {{
+ new Expectations() {{
new ExternalRefProcessor(cache, openAPI);
times = 1;
result = externalRefProcessor;
@@ -178,7 +178,7 @@ public void testProcessRefProperty_ExternalRef() throws Exception {
}
private void expectCallToExternalRefProcessor(final String ref, final RefFormat refFormat, final String newRef) {
- new StrictExpectations() {{
+ new Expectations() {{
externalRefProcessor.processRefToExternalSchema(ref, refFormat);
times = 1;
result = newRef;
@@ -239,7 +239,7 @@ public void testProcessMapProperty_AdditionalPropertiesIsRefProperty() throws Ex
}
private void expectCreationOfExternalRefProcessor() {
- new StrictExpectations() {{
+ 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/OpenAPIResolverTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIResolverTest.java
index fd4c236a92..a02fc929bb 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIResolverTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIResolverTest.java
@@ -47,7 +47,7 @@
import io.swagger.v3.parser.util.ResolverFully;
import mockit.Injectable;
import mockit.Mocked;
-import mockit.StrictExpectations;
+import mockit.Expectations;
import org.apache.commons.io.FileUtils;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
@@ -1066,7 +1066,7 @@ public void testSwaggerResolver(@Injectable final OpenAPI swagger,
@Mocked final ComponentsProcessor componentsProcessor,
@Mocked final PathsProcessor pathsProcessor) throws Exception {
- new StrictExpectations() {{
+ new Expectations() {{
new ResolverCache(swagger, auths, null, new HashSet<>(), parseOptions);
result = cache;
times = 1;
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 d3349aec26..3452e0d01f 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
@@ -16,9 +16,9 @@
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
-import static org.testng.AssertJUnit.assertNotSame;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
@@ -2757,7 +2757,7 @@ public void readingSpecStringShouldNotOverQuotingStringExample() throws Exceptio
@Test(description = "A string example should not be over quoted when parsing a yaml node")
public void readingSpecNodeShouldNotOverQuotingStringExample() throws Exception {
- String yaml = Files.readFile(new File("src/test/resources/over-quoted-example.yaml"));
+ String yaml = Files.readFile(new FileInputStream("src/test/resources/over-quoted-example.yaml"));
JsonNode rootNode = Yaml.mapper().readValue(yaml, JsonNode.class);
OpenAPIV3Parser parser = new OpenAPIV3Parser();
OpenAPI openAPI = (parser.parseJsonNode(null, rootNode)).getOpenAPI();
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/RefUtilsTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/RefUtilsTest.java
index 8c8ab5d34c..84428db730 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/RefUtilsTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/RefUtilsTest.java
@@ -7,20 +7,20 @@
import io.swagger.v3.parser.processors.ExternalRefProcessor;
import mockit.Injectable;
import mockit.Mocked;
-import mockit.StrictExpectations;
+import mockit.Expectations;
import org.apache.commons.io.IOUtils;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -37,6 +37,17 @@
public class RefUtilsTest {
+ List auths;
+
+ @Injectable
+ AuthorizationValue auth1;
+ @Injectable
+ AuthorizationValue auth2;
+ public RefUtilsTest() {
+ List auths = new ArrayList<>();
+ auths.add(auth1);
+ auths.add(auth2);
+ }
@Test
public void testComputeDefinitionName() throws Exception {
//URL refs
@@ -106,15 +117,16 @@ public void testIsAnExternalRefFormat() throws Exception {
}
}
+
+ @Mocked RemoteUrl remoteUrl;
+
@Test
- public void testReadExternalRef_UrlFormat(@Injectable final List auths,
- @Mocked RemoteUrl remoteUrl
- ) throws Exception {
+ public void testReadExternalRef_UrlFormat() throws Exception {
final String url = "http://my.company.com/path/to/file.json";
final String expectedResult = "really good json";
- new StrictExpectations() {{
+ new Expectations() {{
RemoteUrl.urlToString(url, auths);
times = 1;
result = expectedResult;
@@ -128,13 +140,11 @@ public void testReadExternalRef_UrlFormat(@Injectable final List auths,
- @Mocked RemoteUrl remoteUrl
- ) throws Exception {
+ public void testReadExternalRef_UrlFormat_ExceptionThrown() throws Exception {
final String url = "http://my.company.com/path/to/file.json";
- new StrictExpectations() {{
+ new Expectations() {{
RemoteUrl.urlToString(url, auths);
times = 1;
result = new Exception();
@@ -143,23 +153,27 @@ public void testReadExternalRef_UrlFormat_ExceptionThrown(@Injectable final List
RefUtils.readExternalRef(url, RefFormat.URL, auths, null);
}
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder();
+ @Mocked IOUtils ioUtils;
+ @Mocked Files files;
+ @Injectable Path parentDirectory;
+ @Injectable Path pathToUse;
+ public File tempFile(String name) throws Exception{
+ String tmpDir = System.getProperty("java.io.tmpdir");
+ File f = new File(tmpDir + File.separator + name);
+ f.createNewFile();
+ return f;
+ }
@Test
- public void testReadExternalRef_RelativeFileFormat(@Injectable final List auths,
- @Mocked IOUtils ioUtils,
- @Mocked Files files,
- @Injectable final Path parentDirectory,
- @Injectable final Path pathToUse
+ public void testReadExternalRef_RelativeFileFormat(
) throws Exception {
- final String filePath = "file.json";
- File file = tempFolder.newFile(filePath);
+
+ File file = tempFile(filePath);
final String expectedResult = "really good json";
setupRelativeFileExpectations(parentDirectory, pathToUse, file, filePath);
- new StrictExpectations() {{
+ new Expectations() {{
IOUtils.toString((FileInputStream) any, UTF_8);
times = 1;
result = expectedResult;
@@ -171,8 +185,11 @@ public void testReadExternalRef_RelativeFileFormat(@Injectable final List auths,
- @Mocked IOUtils ioUtils,
- @Mocked Files files,
- @Injectable final Path parentDirectory,
- @Injectable final Path pathToUse
- ) throws Exception {
+ public void testReadExternalRef_RelativeFileFormat_ExceptionThrown() throws Exception {
final String filePath = "file.json";
- File file = tempFolder.newFile(filePath);
+ File file = tempFile(filePath);
final String expectedResult = "really good json";
setupRelativeFileExpectations(parentDirectory, pathToUse, file, filePath);
- new StrictExpectations() {{
+ new Expectations() {{
IOUtils.toString((FileInputStream) any, UTF_8);
times = 1;
result = new IOException();
@@ -220,7 +233,7 @@ public boolean matches(Object o) {
}
@Test
- public void testReadExternalRef_InternalFormat(@Injectable final List auths) throws Exception {
+ public void testReadExternalRef_InternalFormat() throws Exception {
final String file = "#/defintiions/foo";
@@ -232,43 +245,10 @@ public void testReadExternalRef_InternalFormat(@Injectable final List
org.testng
testng
- 6.9.10
+ ${testng-version}
test
diff --git a/pom.xml b/pom.xml
index 8875231041..93c1653ace 100644
--- a/pom.xml
+++ b/pom.xml
@@ -73,9 +73,16 @@
org.apache.maven.plugins
maven-surefire-plugin
${surefire-version}
+
+
+ org.apache.maven.surefire
+ surefire-junit4
+ 3.0.0
+
+
none:none
- -Djdk.attach.allowAttachSelf
+ -javaagent:"${settings.localRepository}"/org/jmockit/jmockit/${jmockit-version}/jmockit-${jmockit-version}.jar --add-opens java.base/java.lang=ALL-UNNAMED -Djdk.attach.allowAttachSelf
@@ -108,7 +115,7 @@
org.apache.maven.plugins
maven-jar-plugin
- 2.4
+ 3.3.0
**/logback.xml
@@ -125,16 +132,12 @@
maven-compiler-plugin
- 3.8.1
-
- 1.8
- 1.8
-
+ 3.10.1
org.apache.maven.plugins
maven-javadoc-plugin
- 3.1.1
+ 3.5.0
true
1.8
@@ -157,7 +160,7 @@
org.apache.maven.plugins
maven-source-plugin
- 3.1.0
+ 3.2.1
attach-sources
@@ -171,7 +174,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.1
+ 0.8.8
default-prepare-agent
@@ -204,7 +207,7 @@
org.apache.maven.plugins
maven-enforcer-plugin
- 3.0.0-M2
+ 3.2.1
enforce-no-snapshots
@@ -226,7 +229,7 @@
org.sonatype.plugins
nexus-staging-maven-plugin
- 1.6.8
+ 1.6.13
true
ossrh
@@ -256,7 +259,7 @@
org.apache.maven.plugins
maven-enforcer-plugin
- 3.0.0-M2
+ 3.2.1
@@ -269,7 +272,7 @@
org.owasp
dependency-check-maven
- 6.5.3
+ 8.1.2
true
@@ -402,20 +405,21 @@
- 1.33
- 1.0.64
+ 8
+ 2.0
+ 1.0.65
2.11.0
- 1.7.30
- 2.2.8
- 1.6.9
+ 1.7.36
+ 2.2.9
+ 1.6.10
4.13.2
- 6.14.2
- 1.35
- 2.15.0
- 2.22.2
- 3.2.1
- 2.14.0
- 2.14.0
+ 7.7.1
+ 1.49
+ 2.27.2
+ 3.0.0
+ 3.12.0
+ 2.14.2
+ 2.14.2
UTF-8
https://oss.sonatype.org/content/repositories/snapshots/