Skip to content

Fix example applications #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions examples/springdoc-openapi-scala-1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# springdoc-openapi-scala-2 Example Application

This is a simple example application demonstrating the use of springdoc-openapi-scala with Spring Boot 2.x.

## Prerequisites

- JDK 17 or higher
- SBT 1.x
- Scala 2.12.x

## Running the Application

To run the application with hot-reload enabled:

```bash
cd springdoc-openapi-scala/examples/springdoc-openapi-scala-1/simple
sed -i '' 's/`springdoc-openapi-scala-1-version`: String = \?\?\?/`springdoc-openapi-scala-1-version`: String = "0.3.2"/g' build.sbt # Omit '' after the -i flag if not on mac
sbt compile
sbt "~reStart"
```

The `~reStart` command will automatically restart the application when source files change.

## Accessing the API Documentation

Once the application is running, you can access the OpenAPI documentation at:

- OpenAPI JSON: http://localhost:8080/v3/api-docs

## Features Demonstrated

- Integration of springdoc-openapi with Scala classes
- Automatic schema generation for Scala case classes
- Support for complex type hierarchies
- Custom schema customization

## Project Structure

- `src/main/scala/.../Application.scala` - Spring Boot application entry point
- `src/main/scala/.../OpenAPIConfiguration.scala` - OpenAPI configuration
- `src/main/scala/.../controller/` - REST controllers
- `src/main/scala/.../model/` - Data models
3 changes: 2 additions & 1 deletion examples/springdoc-openapi-scala-1/simple/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ lazy val root = (project in file("."))
"za.co.absa" %% "springdoc-openapi-scala-1" % `springdoc-openapi-scala-1-version`,
"org.springdoc" % "springdoc-openapi-webmvc-core" % "1.7.0",
"org.springframework.boot" % "spring-boot-starter-web" % "2.6.6",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.16.1"
"com.fasterxml.jackson.core" % "jackson-databind" % "2.16.1",
"org.scala-lang" % "scala-reflect" % scalaVersion.value
),
webappWebInfClasses := true,
inheritJarManifest := true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
*/

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.2.4")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0")
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package za.co.absa.springdocopenapiscala.examples.simple
import com.fasterxml.jackson.databind.JsonNode
import io.swagger.v3.oas.models.OpenAPI
import io.swagger.v3.oas.models.info.Info
import io.swagger.v3.oas.models.media.Schema
import io.swagger.v3.oas.models.media.StringSchema
import org.springdoc.core.customizers.OpenApiCustomiser
import org.springframework.context.annotation.{Bean, Configuration}
import za.co.absa.springdocopenapiscala.{Bundle, OpenAPIModelRegistration}
Expand All @@ -39,8 +39,7 @@ class OpenAPIConfiguration {
),
OpenAPIModelRegistration.ExtraTypesHandling.simpleMapping {
case t if t =:= typeOf[JsonNode] =>
val schema = new Schema
schema.setType("string")
val schema = new StringSchema
schema.setFormat("json")
schema
}
Expand Down
42 changes: 42 additions & 0 deletions examples/springdoc-openapi-scala-2/simple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# springdoc-openapi-scala-2 Example Application

This is a simple example application demonstrating the use of springdoc-openapi-scala with Spring Boot 3.x.

## Prerequisites

- JDK 17 or higher
- SBT 1.x
- Scala 2.12.x

## Running the Application

To run the application with hot-reload enabled:

```bash
cd springdoc-openapi-scala/examples/springdoc-openapi-scala-2/simple
sed -i '' 's/`springdoc-openapi-scala-2-version`: String = \?\?\?/`springdoc-openapi-scala-2-version`: String = "0.3.2"/g' build.sbt # Omit '' after the -i flag if not on mac
sbt compile
sbt "~reStart"
```

The `~reStart` command will automatically restart the application when source files change.

## Accessing the API Documentation

Once the application is running, you can access the OpenAPI documentation at:

- OpenAPI JSON: http://localhost:8080/v3/api-docs

## Features Demonstrated

- Integration of springdoc-openapi with Scala classes
- Automatic schema generation for Scala case classes
- Support for complex type hierarchies
- Custom schema customization

## Project Structure

- `src/main/scala/.../Application.scala` - Spring Boot application entry point
- `src/main/scala/.../OpenAPIConfiguration.scala` - OpenAPI configuration
- `src/main/scala/.../controller/` - REST controllers
- `src/main/scala/.../model/` - Data models
2 changes: 1 addition & 1 deletion examples/springdoc-openapi-scala-2/simple/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ lazy val root = (project in file("."))
libraryDependencies ++= Seq(
"za.co.absa" %% "springdoc-openapi-scala-2" % `springdoc-openapi-scala-2-version`,
"org.springdoc" % "springdoc-openapi-starter-webmvc-api" % "2.8.9",
"org.springframework.boot" % "spring-boot-starter-web" % "3.2.0",
"org.springframework.boot" % "spring-boot-starter-web" % "3.4.3",
"org.playframework" %% "play-json" % "3.0.1"
),
webappWebInfClasses := true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
*/

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.2.4")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0")
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package za.co.absa.springdocopenapiscala.examples.simple

import io.swagger.v3.oas.models.OpenAPI
import io.swagger.v3.oas.models.info.Info
import io.swagger.v3.oas.models.media.Schema
import io.swagger.v3.oas.models.media.StringSchema
import org.springdoc.core.customizers.OpenApiCustomizer
import org.springframework.context.annotation.{Bean, Configuration}
import play.api.libs.json.JsValue
Expand All @@ -40,8 +40,7 @@ class OpenAPIConfiguration {
),
OpenAPIModelRegistration.ExtraTypesHandling.simpleMapping {
case t if t =:= typeOf[JsValue] =>
val schema = new Schema
schema.setType("string")
val schema = new StringSchema
schema.setFormat("json")
schema
}
Expand Down
6 changes: 6 additions & 0 deletions publish.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ ThisBuild / developers := List(
name = "Kevin Wallimann",
email = "[email protected]",
url = url("https://github.com/kevinwallimann")
),
Developer(
id = "AlexGuzmanAtAbsa",
name = "Alejandro Guzman",
email = "[email protected]",
url = url("https://github.com/AlexGuzmanAtAbsa")
)
)

Expand Down