-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
115 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/io/github/smiley4/ktorswaggerui/dsl/OpenApiExternalDocs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.github.smiley4.ktorswaggerui.dsl | ||
|
||
/** | ||
* An object representing external documentation. | ||
*/ | ||
@OpenApiDslMarker | ||
class OpenApiExternalDocs { | ||
/** | ||
* A short description of the external documentation | ||
*/ | ||
var description: String? = null | ||
|
||
/** | ||
* A URL to the external documentation | ||
*/ | ||
var url: String = "/" | ||
} |
9 changes: 5 additions & 4 deletions
9
src/main/kotlin/io/github/smiley4/ktorswaggerui/spec/openapi/ExternalDocumentationBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
package io.github.smiley4.ktorswaggerui.spec.openapi | ||
|
||
import io.github.smiley4.ktorswaggerui.dsl.OpenApiExternalDocs | ||
import io.swagger.v3.oas.models.ExternalDocumentation | ||
|
||
|
||
class ExternalDocumentationBuilder { | ||
|
||
fun build(url: String, description: String): ExternalDocumentation = | ||
fun build(externalDocs: OpenApiExternalDocs): ExternalDocumentation = | ||
ExternalDocumentation().also { | ||
it.url = url | ||
it.description = description | ||
it.url = externalDocs.url | ||
it.description = externalDocs.description | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...in/kotlin/io/github/smiley4/ktorswaggerui/spec/openapi/TagExternalDocumentationBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.github.smiley4.ktorswaggerui.spec.openapi | ||
|
||
import io.swagger.v3.oas.models.ExternalDocumentation | ||
|
||
class TagExternalDocumentationBuilder { | ||
|
||
fun build(url: String, description: String): ExternalDocumentation = | ||
ExternalDocumentation().also { | ||
it.url = url | ||
it.description = description | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/kotlin/io/github/smiley4/ktorswaggerui/tests/openapi/ExternalDocsBuilderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.github.smiley4.ktorswaggerui.tests.openapi | ||
|
||
import io.github.smiley4.ktorswaggerui.dsl.OpenApiExternalDocs | ||
import io.github.smiley4.ktorswaggerui.spec.openapi.ExternalDocumentationBuilder | ||
import io.kotest.core.spec.style.StringSpec | ||
import io.kotest.matchers.shouldBe | ||
import io.swagger.v3.oas.models.ExternalDocumentation | ||
|
||
class ExternalDocsBuilderTest : StringSpec({ | ||
|
||
"default external docs object" { | ||
buildExternalDocsObject {}.also { docs -> | ||
docs.url shouldBe "/" | ||
docs.description shouldBe null | ||
} | ||
} | ||
|
||
"complete server object" { | ||
buildExternalDocsObject { | ||
url = "Test URL" | ||
description = "Test Description" | ||
}.also { docs -> | ||
docs.url shouldBe "Test URL" | ||
docs.description shouldBe "Test Description" | ||
} | ||
} | ||
|
||
}) { | ||
|
||
companion object { | ||
|
||
private fun buildExternalDocsObject(builder: OpenApiExternalDocs.() -> Unit): ExternalDocumentation { | ||
return ExternalDocumentationBuilder().build(OpenApiExternalDocs().apply(builder)) | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters