yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator
MIT License
625 stars 146 forks source link

"description" aka doc comments don't get generated nicely #294

Open rogerluan opened 2 years ago

rogerluan commented 2 years ago

Hey 👋

I've found an issue where code like this:

/**
* This is a multiline
* comment.
*/
public myProperty: MyClass[];

Gets translated into this swagger json:

…
"myProperty": {
    "description": "* This is a multiline\n\t *  comment.",
    "items": {
        "$ref": "#/components/schemas/MyClass"
    },
    "type": "array"
},
…

Which SwagGen (understandably) generates this:

// * This is a multiline
 * comment.
public var myProperty: [MyClass]

Although swagger could do a bit better with providing a better generated "description" (e.g. not including the * characters), I think SwagGen should at least provide code that compiles, e.g.:

/// * This is a multiline
/// * comment.
public var myProperty: [MyClass]

In other words: using the dedicated doc comment syntax (///) and adding that delimited to the start of the line so that it's recognized as a doc comment (which makes the code compile).

Has this been considered? Or is there a better way to annotate doc comments in javascript? All the help is highly appreciated 🙏 Thanks!