zio / zio-http

A next-generation Scala framework for building scalable, correct, and efficient HTTP clients and servers
https://zio.dev/zio-http
Apache License 2.0
787 stars 396 forks source link

OpenAPI generation fails with a Map[String, List[String]] #2916

Closed countfloyd closed 2 months ago

countfloyd commented 3 months ago

For a field of type Map[String, List[String]] (or List of anything for that matter), the OpenAPI generator fails

Run this program to reproduce:

import zio.http.endpoint.openapi.JsonSchema
import zio.http.endpoint.openapi.JsonSchema.SchemaStyle
import zio.schema.*

import scala.collection.immutable.List

@main def schema(): Unit =
  val schema = Schema.map[String, List[String]]
  val s = JsonSchema.fromZSchemaMulti(schema, SchemaStyle.Reference)
  println(s.toString)

The OpenAPI generation should succeed. Instead, get this exception:

Exception in thread "main" java.util.NoSuchElementException: None.get
    at scala.None$.get(Option.scala:627)
    at scala.None$.get(Option.scala:626)
    at zio.http.endpoint.openapi.JsonSchema$.fromZSchemaMulti(JsonSchema.scala:378)
    at com.g1.esg1.v10n.web.schema$package$.schema(schema.scala:25)
    at com.g1.esg1.v10n.web.schema.main(schema.scala:23)

Using zio-http 3.0.0-RC8 and Scala 3.4.2

jdegoes commented 2 months ago

/bounty $75 for test case and fix.

algora-pbc[bot] commented 2 months ago

## 💎 $75 bounty • ZIO

### Steps to solve: 1. Start working: Comment /attempt #2916 with your implementation plan 2. Submit work: Create a pull request including /claim #2916 in the PR body to claim the bounty 3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio-http!

Add a bounty • Share on socials

Attempt Started (GMT+0) Solution
🟢 @pawelsadlo Aug 1, 2024, 9:07:26 PM #2996
pawelsadlo commented 2 months ago

/attempt #2916

algora-pbc[bot] commented 2 months ago

💡 @pawelsadlo submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] commented 2 months ago

🎉🎈 @pawelsadlo has been awarded $75! 🎈🎊