Skip to content

Commit d16e85e

Browse files
Fix String/Boolean serialization (serialize to Any). Fix optional/mandatory specification for all types
1 parent 570d482 commit d16e85e

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The library has springdoc-openapi as a provided dependency,
3232
thus users of the library have to include that dependency in their projects:
3333
- for springdoc-openapi 1.x versions `1.6.7` up to `1.7.0` (including) of
3434
`"org.springdoc" % "springdoc-openapi-webmvc-core"` are supported
35-
- for springdoc-openapi 2.x versions `2.0.0` up to `2.3.0` (including) of
35+
- for springdoc-openapi 2.x versions `2.0.0` up to `2.8.9` (including) of
3636
`"org.springdoc" % "springdoc-openapi-starter-webmvc-api"` are supported
3737

3838
### Add library dependency to SBT/Maven

examples/springdoc-openapi-scala-2/simple/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ lazy val root = (project in file("."))
2222
.settings(
2323
libraryDependencies ++= Seq(
2424
"za.co.absa" %% "springdoc-openapi-scala-2" % `springdoc-openapi-scala-2-version`,
25-
"org.springdoc" % "springdoc-openapi-starter-webmvc-api" % "2.3.0",
25+
"org.springdoc" % "springdoc-openapi-starter-webmvc-api" % "2.8.9",
2626
"org.springframework.boot" % "spring-boot-starter-web" % "3.2.0",
2727
"org.playframework" %% "play-json" % "3.0.1"
2828
),

library/src/main/scala/za/co/absa/springdocopenapiscala/OpenAPIScalaCustomizer.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package za.co.absa.springdocopenapiscala
1818

19+
import io.swagger.v3.core.util.Json
1920
import io.swagger.v3.oas.models.{Components, OpenAPI}
2021
import za.co.absa.springdocopenapiscala.SpringdocOpenAPIVersionSpecificTypes.OpenApiCustomizer
2122

@@ -29,6 +30,21 @@ class OpenAPIScalaCustomizer(components: Components) extends OpenApiCustomizer {
2930
openAPIOutOfSync.setComponents(components)
3031

3132
fixResponsesReturningUnit(openAPIOutOfSync)
33+
34+
val jsonRepresentation = Json.pretty(openAPIOutOfSync)
35+
36+
// Deserialize the JSON string back into a new OpenAPI object
37+
val newOpenAPI = Json.mapper().readValue(jsonRepresentation, classOf[OpenAPI])
38+
39+
// Replace the root by copying properties from the new OpenAPI object
40+
openAPIOutOfSync.setComponents(newOpenAPI.getComponents)
41+
openAPIOutOfSync.setPaths(newOpenAPI.getPaths)
42+
openAPIOutOfSync.setInfo(newOpenAPI.getInfo)
43+
openAPIOutOfSync.setServers(newOpenAPI.getServers)
44+
openAPIOutOfSync.setSecurity(newOpenAPI.getSecurity)
45+
openAPIOutOfSync.setTags(newOpenAPI.getTags)
46+
openAPIOutOfSync.setExternalDocs(newOpenAPI.getExternalDocs)
47+
openAPIOutOfSync.setExtensions(newOpenAPI.getExtensions)
3248
}
3349

3450
private def fixResponsesReturningUnit(openAPI: OpenAPI): Unit = {

project/Dependencies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ object Dependencies {
2727

2828
def springdocOpenapi(majorVersion: Int): String = majorVersion match {
2929
case 1 => "[1.6.7,1.7.0]"
30-
case 2 => "[2.0.0,2.3.0]"
30+
case 2 => "[2.0.0,2.8.9]"
3131
}
3232
}
3333

0 commit comments

Comments
 (0)