Skip to content

Commit fdfff63

Browse files
Update README.md (#31)
1 parent 5cd85e3 commit fdfff63

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

README.md

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

3737
### Add library dependency to SBT/Maven
@@ -50,31 +50,39 @@ If you want to use the library with springdoc-openapi 1.x, add:
5050
```xml
5151
<dependency>
5252
<groupId>za.co.absa</groupId>
53-
<artifactId>springdoc-openapi-scala-1_{scala_binary_version}</artifactId>
53+
<artifactId>springdoc-openapi-scala-1_${scala_binary_version}</artifactId>
5454
<version>${version}</version>
5555
</dependency>
5656
```
5757
if with springdoc-openapi 2.x, add:
5858
```xml
5959
<dependency>
6060
<groupId>za.co.absa</groupId>
61-
<artifactId>springdoc-openapi-scala-2_{scala_binary_version}</artifactId>
61+
<artifactId>springdoc-openapi-scala-2_${scala_binary_version}</artifactId>
6262
<version>${version}</version>
6363
</dependency>
6464
```
6565

6666
where `scala_binary_version` is either `2.12` or `2.13`.
6767

6868
### Create custom OpenAPI Spring Configuration
69+
For springdoc-openapi 1.x
6970
```scala
71+
import io.swagger.v3.oas.models.OpenAPI
72+
import io.swagger.v3.oas.models.info.Info
73+
import org.springdoc.core.customizers.OpenApiCustomiser
74+
import org.springframework.context.annotation.{Bean, Configuration}
75+
76+
import za.co.absa.springdocopenapiscala.{Bundle, OpenAPIModelRegistration}
77+
7078
@Configuration
7179
class OpenAPIConfiguration {
7280

7381
private val springDocOpenAPIScalaBundle = new Bundle(
7482
Seq((openAPI: OpenAPI) =>
7583
openAPI.setInfo(
7684
new Info()
77-
.title("Example API")
85+
.title("Example API with springdoc-openapi v1.x")
7886
.version("1.0.0")
7987
)
8088
)
@@ -89,6 +97,37 @@ class OpenAPIConfiguration {
8997
}
9098
```
9199

100+
For springdoc-openapi 2.x
101+
```scala
102+
import io.swagger.v3.oas.models.OpenAPI
103+
import io.swagger.v3.oas.models.info.Info
104+
import org.springdoc.core.customizers.OpenApiCustomizer
105+
import org.springframework.context.annotation.{Bean, Configuration}
106+
107+
import za.co.absa.springdocopenapiscala.{Bundle, OpenAPIModelRegistration}
108+
109+
@Configuration
110+
class OpenAPIConfiguration {
111+
112+
private val springDocOpenAPIScalaBundle = new Bundle(
113+
Seq((openAPI: OpenAPI) =>
114+
openAPI.setInfo(
115+
new Info()
116+
.title("Example API with springdoc-openapi v2.x")
117+
.version("1.0.0")
118+
)
119+
)
120+
)
121+
122+
@Bean
123+
def openAPICustomizer: OpenApiCustomizer = springDocOpenAPIScalaBundle.customizer
124+
125+
@Bean
126+
def openAPIModelRegistration: OpenAPIModelRegistration = springDocOpenAPIScalaBundle.modelRegistration
127+
128+
}
129+
```
130+
92131
### Register top-level model case classes (for example in Controller)
93132
Example model:
94133
```scala

0 commit comments

Comments
 (0)