Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Swagger parse(String swaggerAsString, List<AuthorizationValue> auths) {
Swagger output;
try {
output = new Swagger20Parser().parse(swaggerAsString);
if (output != null && auths != null && auths.size() > 0) {
if (output != null) {
return new SwaggerResolver().resolve(output, auths);
}
} catch (IOException e) {
Expand Down
17 changes: 17 additions & 0 deletions modules/swagger-parser/src/test/scala/SwaggerReaderTest.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import io.swagger.models.Swagger
import io.swagger.parser.SwaggerParser
import io.swagger.util.Json
import org.apache.commons.io.FileUtils
import org.junit.runner.RunWith
import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.junit.JUnitRunner

import java.io.File
import java.nio.charset.StandardCharsets

@RunWith(classOf[JUnitRunner])
class SwaggerReaderTest extends FlatSpec with Matchers {
val m = Json.mapper()
Expand Down Expand Up @@ -41,4 +46,16 @@ class SwaggerReaderTest extends FlatSpec with Matchers {
}"""
)
}

it should "read the issue 59 resource" in {
val parser = new SwaggerParser()
val sampleFilePath = "./src/test/resources/uber.json"

val swaggerFromFile = parser.parse(FileUtils.readFileToString(new File(sampleFilePath), StandardCharsets.UTF_8))
val swaggerFromString = parser.read(sampleFilePath)

swaggerFromFile.isInstanceOf[Swagger] should be(true)
swaggerFromString.isInstanceOf[Swagger] should be(true)
swaggerFromFile should equal(swaggerFromString)
}
}