Skip to content

Commit b7e672f

Browse files
committed
Added some OpenAPI doc
1 parent 5f1d51b commit b7e672f

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ val mockkVersion = "1.12.0"
44
val logstashVersion = "6.6"
55
val springVersion = "2.5.5"
66
val testContainersVersion = "1.16.0"
7+
val springFoxVersion = "3.0.0"
78

89
repositories {
910
mavenCentral()
@@ -27,6 +28,8 @@ dependencies {
2728
implementation("org.springframework.boot:spring-boot-starter-webflux")
2829
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
2930

31+
implementation("io.springfox:springfox-boot-starter:$springFoxVersion")
32+
3033
implementation("org.flywaydb:flyway-core")
3134
implementation("com.zaxxer:HikariCP")
3235
implementation("org.postgresql:postgresql")

src/main/kotlin/no/nav/klage/document/api/DocumentController.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package no.nav.klage.document.api
22

3+
import io.swagger.annotations.ApiOperation
34
import no.nav.klage.document.api.views.CommentInput
45
import no.nav.klage.document.api.views.CommentView
56
import no.nav.klage.document.api.views.DocumentView
@@ -23,6 +24,10 @@ class DocumentController(
2324
private val logger = getLogger(javaClass.enclosingClass)
2425
}
2526

27+
@ApiOperation(
28+
value = "Create document",
29+
notes = "Create document"
30+
)
2631
@PostMapping("/")
2732
fun createDocument(
2833
@RequestBody json: String
@@ -31,12 +36,20 @@ class DocumentController(
3136
return mapToDocumentView(documentService.createDocument(json))
3237
}
3338

39+
@ApiOperation(
40+
value = "Get document",
41+
notes = "Get document"
42+
)
3443
@GetMapping("/{documentId}")
3544
fun getDocument(@PathVariable("documentId") documentId: UUID): DocumentView {
3645
logger.debug("getDocument")
3746
return mapToDocumentView(documentService.getDocument(documentId))
3847
}
3948

49+
@ApiOperation(
50+
value = "Create comment for a given document",
51+
notes = "Create comment for a given document"
52+
)
4053
@PostMapping("/{documentId}/comments")
4154
fun createComment(
4255
@PathVariable("documentId") documentId: UUID,
@@ -53,6 +66,10 @@ class DocumentController(
5366
)
5467
}
5568

69+
@ApiOperation(
70+
value = "Get all comments for a given document",
71+
notes = "Get all comments for a given document"
72+
)
5673
@GetMapping("/{documentId}/comments")
5774
fun getAllCommentsWithPossibleThreads(
5875
@PathVariable("documentId") documentId: UUID
@@ -61,6 +78,10 @@ class DocumentController(
6178
return commentService.getComments(documentId).map { mapCommentToView(it) }
6279
}
6380

81+
@ApiOperation(
82+
value = "Reply to a given comment",
83+
notes = "Reply to a given comment"
84+
)
6485
@PostMapping("/{documentId}/comments/{commentId}")
6586
fun replyToComment(
6687
@PathVariable("documentId") documentId: UUID,
@@ -79,6 +100,10 @@ class DocumentController(
79100
)
80101
}
81102

103+
@ApiOperation(
104+
value = "Get a given comment",
105+
notes = "Get a given comment"
106+
)
82107
@GetMapping("/{documentId}/comments/{commentId}")
83108
fun getCommentWithPossibleThread(
84109
@PathVariable("documentId") documentId: UUID,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package no.nav.klage.document.config
2+
3+
import no.nav.klage.document.api.DocumentController
4+
import org.springframework.context.annotation.Bean
5+
import org.springframework.context.annotation.Configuration
6+
import org.springframework.http.ResponseEntity
7+
import springfox.documentation.builders.RequestHandlerSelectors
8+
import springfox.documentation.service.Tag
9+
import springfox.documentation.spi.DocumentationType
10+
import springfox.documentation.spring.web.plugins.Docket
11+
12+
@Configuration
13+
class OpenApiConfig {
14+
15+
@Bean
16+
fun apiInternal(): Docket {
17+
return Docket(DocumentationType.OAS_30)
18+
.select()
19+
.apis(RequestHandlerSelectors.basePackage(DocumentController::class.java.packageName))
20+
.build()
21+
.pathMapping("/")
22+
.genericModelSubstitutes(ResponseEntity::class.java)
23+
.tags(Tag("kabal-smart-editor-api", "API for smart-editor"))
24+
}
25+
26+
}

0 commit comments

Comments
 (0)