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] The generator doesn't strip the `description` of a type when the `description` comes from the Javadoc of the type #3047

Closed guizmaii closed 1 month ago

guizmaii commented 1 month ago

With the following code:

/**
 * This is the Input documentation
 */
final case class Input(a: String)

val testEndpoint = 
  (Endpoint(RoutePattern.POST / "test") ?? Doc.p("This is my 'POST /test' endpoint doc"))
    .in[Input]
    .out[String](mediaType = MediaType.application.json, doc = Doc.p("this is the output doc"))

val spec: String =
  OpenAPIGen.fromEndpoints(
    title = "This is my OpenAPI doc title",
    version = "0.0.0",
    endpoints = List(testEndpoint)
  ).toJson

The spec will contain the following description for the Input type:

"description": "/**\n     * This is the Input documentation\n     */"

While it should contain:

"description": "This is the Input documentation"

Why is it an issue? Because when we then generate a TS SDK out of the generated OpenAPI spec, the generated code doesn't compile.

@geeeezmo Do you want to give this issue a try?

jdegoes commented 1 month ago

/bounty $75

algora-pbc[bot] commented 1 month ago

💎 $75 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #3047 with your implementation plan
  2. Submit work: Create a pull request including /claim #3047 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
🟢 @987Nabil #3071
987Nabil commented 1 month ago

~If there is both, I am not sure what the right behavior is. Should doc override or add?~ Got it wrong. It is about sanitizing the string. I am not sure, if it should be done here or in schema

geeeezmo commented 1 month ago

@guizmaii on what branch does this happen? I've run the test on main and the annotation doesn't appear in the generated spec.

algora-pbc[bot] commented 1 month ago

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

algora-pbc[bot] commented 1 month ago

🎉🎈 @987Nabil has been awarded $75! 🎈🎊