carlosedp / scala3-quarkus-quickstart

A Sample Scala 3 / Quarkus application with Kafka, persistence and tests.
Apache License 2.0
33 stars 5 forks source link

Swagger to understand Scala types #174

Open lmlynik opened 1 month ago

lmlynik commented 1 month ago

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

carlosedp commented 1 month ago

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 commented 1 month ago

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.

lmlynik commented 1 month ago

Thanks @carlosedp , this worked for the enum!

carlosedp commented 1 month ago

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