Skip to content

Commit 1cc82e0

Browse files
committed
release 1.3.0
this release introduces a breaking change in `securityScheme` which now has a new first parameter `name`. closes #95
1 parent dea09af commit 1cc82e0

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ kotlin-openapi3-dsl is available on maven central
1212
### gradle
1313

1414
```groovy
15-
compile "cc.vileda:kotlin-openapi3-dsl:1.2.0"
15+
compile "cc.vileda:kotlin-openapi3-dsl:1.3.0"
1616
```
1717

1818
### maven
1919
```xml
2020
<dependency>
2121
<groupId>cc.vileda</groupId>
2222
<artifactId>kotlin-openapi3-dsl</artifactId>
23-
<version>1.2.0</version>
23+
<version>1.3.0</version>
2424
</dependency>
2525
```
2626

build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ apply plugin: 'maven-publish'
1616
apply plugin: 'signing'
1717

1818
group 'cc.vileda'
19-
version '1.2.0'
19+
version '1.3.0'
2020

2121
repositories {
2222
mavenCentral()
@@ -120,4 +120,12 @@ compileKotlin {
120120
}
121121
compileTestKotlin {
122122
kotlinOptions.jvmTarget = "1.8"
123+
}
124+
compileJava {
125+
sourceCompatibility = 1.8
126+
targetCompatibility = 1.8
127+
}
128+
compileTestJava {
129+
sourceCompatibility = 1.8
130+
targetCompatibility = 1.8
123131
}

src/main/kotlin/cc/vileda/openapi/dsl/OpenApiDsl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ inline fun <reified T> Components.schema() {
125125
schemas.put(T::class.java.simpleName, schema)
126126
}
127127

128-
fun Components.securityScheme(init: SecurityScheme.() -> Unit) {
128+
fun Components.securityScheme(name: String, init: SecurityScheme.() -> Unit) {
129129
val security = SecurityScheme()
130130
security.init()
131131
securitySchemes = securitySchemes ?: mutableMapOf()
132132

133133
// Security schemes will not validate with a name value. Use https://editor.swagger.io to validate.
134134
// Use the type as the name. see https://swagger.io/docs/specification/authentication/
135-
securitySchemes.put(security.type.toString(), security)
135+
addSecuritySchemes(name, security)
136136
}
137137

138138
fun SecurityScheme.flows(init: OAuthFlows.() -> Unit) {

src/test/kotlin/cc/vileda/openapi/dsl/OpenApiDslTest.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ data class AnotherExampleSchema(val bar: String)
1919
data class ExampleRequestSchema(val foo: String)
2020
data class ListExampleSchema(val baz: List<ExampleSchema>)
2121

22-
enum class ExampleEnum { ONE, TWO }
22+
@Suppress("unused")
23+
enum class ExampleEnum {
24+
ONE,
25+
TWO
26+
}
2327

2428
class OpenApi3BuilderTest : StringSpec() {
2529
init {
@@ -52,9 +56,9 @@ class OpenApi3BuilderTest : StringSpec() {
5256
schema<AnotherExampleSchema>()
5357
schema<ListExampleSchema>()
5458
schema<ExampleEnum>()
55-
securityScheme {
59+
securityScheme("bearer") {
5660
type = SecurityScheme.Type.OPENIDCONNECT
57-
openIdConnectUrl = "http://localhost/auth"
61+
openIdConnectUrl = "http://localhost:8080/auth"
5862
flows {
5963
implicit {
6064
authorizationUrl = "http://localhost:8080/auth"
@@ -153,10 +157,11 @@ class OpenApi3BuilderTest : StringSpec() {
153157
api.info.title shouldBe "jjjj"
154158
api.info.version shouldBe "1.0"
155159
val securityScheme =
156-
api.components.securitySchemes[SecurityScheme.Type.OPENIDCONNECT.toString()]
160+
api.components.securitySchemes["bearer"]
157161
securityScheme shouldNotBe null
158162
securityScheme!!.flows!!.implicit shouldNotBe null
159163
securityScheme.flows.implicit!!.extensions!!["x-internal"] shouldBe true
164+
securityScheme.type shouldBe SecurityScheme.Type.OPENIDCONNECT
160165

161166
val postOp = api.paths["foo"]!!.readOperationsMap()!![PathItem.HttpMethod.POST]
162167
postOp shouldNotBe null

0 commit comments

Comments
 (0)