-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
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
Endpoint API: OpenAPI documentation generator crashes on parameterized case classes #2767
Comments
I’ve also experienced the same issue as reported. Update: I've found a workaround - manually generating the Schema with a simple id. Example: given [V <: ValidationStatus]: Schema[CreateItemInput[V]] =
Schema.CaseClass3[String, Money, ProductType, CreateItemInput[V]](
id0 = TypeId.fromTypeName("CreateItemInput"), // <- "simple" id
field01 = Schema.Field(name0 = "name", schema0 = Schema[String], get0 = _.name, set0 = (v, x) => v.copy(name = x)),
field02 =
Schema.Field(name0 = "price", schema0 = Schema[Money], get0 = _.price, set0 = (v, x) => v.copy(price = x)),
field03 = Schema.Field(
name0 = "productType",
schema0 = Schema[ProductType],
get0 = _.productType,
set0 = (v, x) => v.copy(productType = x),
),
construct0 = (name, price, productType) => CreateItemInput[V](name, price, productType),
)
|
/bounty $150 |
💎 $150 bounty • ZIOSteps to solve:
Thank you for contributing to zio/zio-http! Add a bounty • Share on socials
|
This comment was marked as spam.
This comment was marked as spam.
I think it would be nice if the name generated for openapi be specified with its type parameters (i.e. Data_String) instead of just Data. Systems that consume the openapi json or yaml file could then generate the correct code for different instances of the parameterized type. |
@jdegoes This problem is not solvable in a clean way in zio-http. We need to fix this in zio-schema.
|
💡 @987Nabil submitted a pull request that claims the bounty. You can visit your bounty board to reward. |
🎉🎈 @987Nabil has been awarded $150! 🎈🎊 |
Describe the bug
With parameterized case class used as endpoint's output, Open API documentation generator crashes.
To Reproduce
Steps to reproduce the behaviour:
(Caused by the fact that
zio.http.endpoint.openapi.OpenAPI.Key.fromString("Data[A]")
returnsNone
.)Expected behaviour
I expect correct Open API documentation to be generated, or, at a minimum, no crashes ;)
The text was updated successfully, but these errors were encountered: