Skip to content

Commit 52aa79f

Browse files
committed
Use SpringDoc instead of SpringFox.
1 parent 5e7df03 commit 52aa79f

File tree

4 files changed

+39
-45
lines changed

4 files changed

+39
-45
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ val mockkVersion = "1.12.7"
44
val logstashVersion = "7.2"
55
val springVersion = "2.5.5"
66
val testContainersVersion = "1.17.3"
7-
val springFoxVersion = "3.0.0"
7+
val springDocVersion = "1.6.11"
88
val tokenValidationVersion = "2.1.4"
99

1010
repositories {
@@ -32,7 +32,7 @@ dependencies {
3232

3333
implementation("no.nav.security:token-validation-spring:$tokenValidationVersion")
3434

35-
implementation("io.springfox:springfox-boot-starter:$springFoxVersion")
35+
implementation("org.springdoc:springdoc-openapi-ui:$springDocVersion")
3636

3737
implementation("org.flywaydb:flyway-core")
3838
implementation("com.zaxxer:HikariCP")

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

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

3-
import io.swagger.annotations.Api
4-
import io.swagger.annotations.ApiOperation
3+
import io.swagger.v3.oas.annotations.Operation
4+
import io.swagger.v3.oas.annotations.tags.Tag
55
import no.nav.klage.document.api.views.CommentInput
66
import no.nav.klage.document.api.views.CommentView
77
import no.nav.klage.document.api.views.DocumentView
@@ -23,7 +23,7 @@ import java.util.*
2323

2424
@RestController
2525
@ProtectedWithClaims(issuer = ISSUER_AAD)
26-
@Api(tags = ["kabal-smart-editor-api"])
26+
@Tag(name = "kabal-smart-editor-api")
2727
@RequestMapping("/documents")
2828
class DocumentController(
2929
private val documentService: DocumentService,
@@ -37,9 +37,9 @@ class DocumentController(
3737
private val secureLogger = getSecureLogger()
3838
}
3939

40-
@ApiOperation(
41-
value = "Create document",
42-
notes = "Create document"
40+
@Operation(
41+
summary = "Create document",
42+
description = "Create document"
4343
)
4444
@PostMapping("")
4545
fun createDocument(
@@ -50,9 +50,9 @@ class DocumentController(
5050
return mapToDocumentView(documentService.createDocument(json))
5151
}
5252

53-
@ApiOperation(
54-
value = "Update document",
55-
notes = "Update document"
53+
@Operation(
54+
summary = "Update document",
55+
description = "Update document"
5656
)
5757
@PutMapping("/{documentId}")
5858
fun updateDocument(
@@ -64,29 +64,29 @@ class DocumentController(
6464
return mapToDocumentView(documentService.updateDocument(documentId, json))
6565
}
6666

67-
@ApiOperation(
68-
value = "Get document",
69-
notes = "Get document"
67+
@Operation(
68+
summary = "Get document",
69+
description = "Get document"
7070
)
7171
@GetMapping("/{documentId}")
7272
fun getDocument(@PathVariable("documentId") documentId: UUID): DocumentView {
7373
log("getDocument called with id $documentId")
7474
return mapToDocumentView(documentService.getDocument(documentId))
7575
}
7676

77-
@ApiOperation(
78-
value = "Delete document",
79-
notes = "Delete document"
77+
@Operation(
78+
summary = "Delete document",
79+
description = "Delete document"
8080
)
8181
@DeleteMapping("/{documentId}")
8282
fun deleteDocument(@PathVariable("documentId") documentId: UUID) {
8383
log("deleteDocument called with id $documentId")
8484
documentService.deleteDocument(documentId)
8585
}
8686

87-
@ApiOperation(
88-
value = "Create comment for a given document",
89-
notes = "Create comment for a given document"
87+
@Operation(
88+
summary = "Create comment for a given document",
89+
description = "Create comment for a given document"
9090
)
9191
@PostMapping("/{documentId}/comments")
9292
fun createComment(
@@ -104,9 +104,9 @@ class DocumentController(
104104
)
105105
}
106106

107-
@ApiOperation(
108-
value = "Get all comments for a given document",
109-
notes = "Get all comments for a given document"
107+
@Operation(
108+
summary = "Get all comments for a given document",
109+
description = "Get all comments for a given document"
110110
)
111111
@GetMapping("/{documentId}/comments")
112112
fun getAllCommentsWithPossibleThreads(
@@ -116,9 +116,9 @@ class DocumentController(
116116
return commentService.getComments(documentId).map { mapCommentToView(it) }
117117
}
118118

119-
@ApiOperation(
120-
value = "Reply to a given comment",
121-
notes = "Reply to a given comment"
119+
@Operation(
120+
summary = "Reply to a given comment",
121+
description = "Reply to a given comment"
122122
)
123123
@PostMapping("/{documentId}/comments/{commentId}/replies")
124124
fun replyToComment(
@@ -138,9 +138,9 @@ class DocumentController(
138138
)
139139
}
140140

141-
@ApiOperation(
142-
value = "Get a given comment",
143-
notes = "Get a given comment"
141+
@Operation(
142+
summary = "Get a given comment",
143+
description = "Get a given comment"
144144
)
145145
@GetMapping("/{documentId}/comments/{commentId}")
146146
fun getCommentWithPossibleThread(
@@ -151,9 +151,9 @@ class DocumentController(
151151
return mapCommentToView(commentService.getComment(commentId = commentId))
152152
}
153153

154-
@ApiOperation(
155-
value = "Generer PDF",
156-
notes = "Generer PDF"
154+
@Operation(
155+
summary = "Generer PDF",
156+
description = "Generer PDF"
157157
)
158158
@ResponseBody
159159
@GetMapping("/{documentId}/pdf")
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
package no.nav.klage.document.config
22

33
import no.nav.klage.document.api.DocumentController
4+
import org.springdoc.core.GroupedOpenApi
45
import org.springframework.context.annotation.Bean
56
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
117

128
@Configuration
139
class OpenApiConfig {
1410

1511
@Bean
16-
fun apiInternal(): Docket {
17-
return Docket(DocumentationType.OAS_30)
18-
.select()
19-
.apis(RequestHandlerSelectors.basePackage(DocumentController::class.java.packageName))
12+
fun apiInternal(): GroupedOpenApi {
13+
return GroupedOpenApi.builder()
14+
.packagesToScan(DocumentController::class.java.packageName)
15+
.group("default")
16+
.pathsToMatch("/**")
2017
.build()
21-
.pathMapping("/")
22-
.genericModelSubstitutes(ResponseEntity::class.java)
23-
.tags(Tag("kabal-smart-editor-api", "API for smart-editor"))
2418
}
2519

2620
}

src/main/kotlin/no/nav/klage/document/config/SecurityConfiguration.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package no.nav.klage.document.config
33
import no.nav.security.token.support.spring.api.EnableJwtTokenValidation
44
import org.springframework.context.annotation.Configuration
55

6-
@EnableJwtTokenValidation(ignore = ["springfox"])
6+
@EnableJwtTokenValidation(ignore = ["org.springdoc"])
77
@Configuration
88
internal class SecurityConfiguration {
99

0 commit comments

Comments
 (0)