8000 GitHub Β· Where software is built
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Endpoint API: OpenAPI documentation generator crashes on parameterized case classesΒ #2767
Closed
@dubinsky

Description

@dubinsky

Describe the bug

With parameterized case class used as endpoint's output, Open API documentation generator crashes.

To Reproduce
Steps to reproduce the behaviour:

  1. Run the following code:
//> using scala 3.4.0
//> using dep dev.zio::zio-http:3.0.0-RC6

import zio.http.Method
import zio.http.endpoint.Endpoint
import zio.http.endpoint.openapi.JsonSchema.SchemaStyle
import zio.http.endpoint.openapi.OpenAPIGen
import zio.schema.{DeriveSchema, Schema}

object OpenAPIBug:
  final case class Item(isEdited: Boolean)
  given Schema[Item] = DeriveSchema.gen[Item]
  final case class Data[A](data: List[A])
  given dataSchema[A: Schema]: Schema[Data[A]] = DeriveSchema.gen[Data[A]]
  def main(args: Array[String]): Unit = OpenAPIGen.fromEndpoints(SchemaStyle.Reference, List(
    Endpoint(Method.GET / "bug").out[Data[Item]]
  ))
  1. Observe the following exception:
java.util.NoSuchElementException: None.get
  at zio.http.endpoint.openapi.OpenAPIGen$$anon$7.applyOrElse(OpenAPIGen.scala:707)

(Caused by the fact that zio.http.endpoint.openapi.OpenAPI.Key.fromString("Data[A]") returns None.)

Expected behaviour
I expect correct Open API documentation to be generated, or, at a minimum, no crashes ;)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0