scala3-quarkus-quickstart icon indicating copy to clipboard operation
scala3-quarkus-quickstart copied to clipboard

Swagger to understand Scala types

Open lmlynik opened this issue 1 year ago • 4 comments

Currently this project doesn't work correctly with native Scala types like Option, Iterables and Enums.

{
  "userId": 0,
  "activityType": {},
  "timestamp": "2022-03-10T12:15:50",
  "value": {
    "empty": true,
    "defined": true
  }
}

https://github.com/quarkusio/quarkus/discussions/43812.

Not sure how to get it working correctly even with help from MikeEdgar

lmlynik avatar Oct 17 '24 18:10 lmlynik

From my understanding, this should be added in https://github.com/smallrye/smallrye-open-api or in a new library that adds the Scala types to the smallrye openapi generator. Os course the scala 3 Quarkus extension could also host this.

I'm not too versed into the smallrye code so it's I can't help much... at least now.

carlosedp avatar Oct 18 '24 13:10 carlosedp

About having your enum ActivityType class being shown as a String, you can annotate it like:

@Schema(implementation = classOf[ActivityType])
enum ActivityType {
  case Login, JurisdictionChange, Bet, Deposit, Withdrawal
}

See if it helps.

Still investigating on how to handle Option.

carlosedp avatar Oct 18 '24 14:10 carlosedp

Thanks @carlosedp , this worked for the enum!

lmlynik avatar Oct 18 '24 17:10 lmlynik

Nice, let's keep this open to track eventual workarounds or updates.

carlosedp avatar Oct 18 '24 17:10 carlosedp