We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Tapir version: 1.11.12
Scala version: 3.6.1
the following code:
import sttp.tapir.Schema.annotations.customise import sttp.tapir.generic.auto.* import sttp.tapir.json.circe.* import sttp.tapir.codec.enumeratum.{schemaForShortEnumEntry, schemaForIntEnumEntry} import sttp.tapir.docs.apispec.DocsExtensionAttribute.* @customise(s => s.docsExtension("x-enum-varnames", List("UnPaid", "Paid", "Finish", "Cancel"))) sealed abstract class OrderStatus(val value: Short) extends ShortEnumEntry object OrderStatus extends ShortEnum[OrderStatus] with ShortCirceEnum[OrderStatus] { case object UnPaid extends OrderStatus(0) case object Paid extends OrderStatus(1) case object Finish extends OrderStatus(2) case object Cancel extends OrderStatus(3) val values = findValues given orderStatusTypeMapper: TypeMapper[OrderStatus] = new TypeMapper[OrderStatus] { def jdbcType: JDBCType = JDBCType.TINYINT def get(r: ResultSet, idx: Int): OrderStatus = OrderStatus.withValue(r.getShort(idx)) def put(r: PreparedStatement, idx: Int, v: OrderStatus): Unit = r.setShort(idx, v.value) } }
would output:
components: schemas: OrderStatus: title: OrderStatus type: integer enum: - '0' - '1' - '2' - '3'
problems are:
If I chnage the code to:
sealed abstract class OrderStatus(val value: Short) extends ShortEnumEntry object OrderStatus extends ShortEnum[OrderStatus] with ShortCirceEnum[OrderStatus] { case object UnPaid extends OrderStatus(0) case object Paid extends OrderStatus(1) case object Finish extends OrderStatus(2) case object Cancel extends OrderStatus(3) val values = findValues import sttp.tapir.codec.enumeratum.schemaForShortEnumEntry given Schema[OrderStatus] = { schemaForShortEnumEntry[OrderStatus] .docsExtension("x-enum-varnames", List("UnPaid", "Paid", "Finish", "Cancel")).format("int32") } }
the output. would be
OrderStatus: title: OrderStatus type: integer enum: - '0' - '1' - '2' - '3' format: int32 x-enum-varnames: - UnPaid - Paid - Finish - Cancel
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Tapir version: 1.11.12
Scala version: 3.6.1
the following code:
would output:
problems are:
If I chnage the code to:
the output. would be
The text was updated successfully, but these errors were encountered: