zio-http icon indicating copy to clipboard operation
zio-http copied to clipboard

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

Open countfloyd opened this issue 1 year ago • 0 comments

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)
  • OS: macOS 14.5
  • Version Java 22

Using zio-http 3.0.0-RC8 and Scala 3.4.2

countfloyd avatar Jun 17 '24 21:06 countfloyd