Skip to content

Commit

Permalink
ref swagger-api#214 - Vendor Extensions support in API Info
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Ciuloaica committed Dec 27, 2019
1 parent 7ddfaa3 commit 299a868
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

api.version = beta

swagger.filter = null
swagger.api {
basepath = "/"
host = "localhost:9000"
title = "Test API"
schemes = []

info {
title = "Test"
description = "Test API endpoint"
termsOfServiceUrl = ""
contact = "[email protected]"
license = "Apache2"
licenseUrl = "http://licenseUrl" # needs to be a valid url to validate against schema
x-api-key: "test"
x-tags: ["test", "api"]
}
}
25 changes: 25 additions & 0 deletions src/test/scala/PlayApiInfoConfigParserSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import com.typesafe.config.ConfigFactory
import org.specs2.mutable.Specification
import play.modules.swagger.PlaySwaggerConfig

class PlayApiInfoConfigParserSpec extends Specification {

private val config = ConfigFactory.load()

"API Info " should {
"proper build Info object" in {
val probe = PlaySwaggerConfig(config)
probe.title === "Test"
probe.description === "Test API endpoint"
probe.termsOfServiceUrl.isEmpty === true
probe.contact === "[email protected]"
probe.license === "Apache2"
probe.licenseUrl === "http://licenseUrl"
probe.vendorExtensions.size shouldEqual(2)
probe.vendorExtensions.head.name === "x-api-key"
probe.vendorExtensions.head.value === "test"
probe.vendorExtensions.tail.head.name === "x-tags"
probe.vendorExtensions.tail.head.value === java.util.Arrays.asList("test", "api")
}
}
}

0 comments on commit 299a868

Please sign in to comment.