swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

Code generation crashes if description has `*/` substring

Open m-Bilal opened this issue 10 months ago • 3 comments

If any description in the Open API Document has */ substring, then that causes the multiline comment used for description to end early, resulting in a syntax error.

I know one way of fixing this could be to preprocess the schema and replace this substring with something else (like *'/) in the onInit hook, but:

  1. Is there a simpler way of doing it where I don't need to traverse the whole schema and look at every description?
  2. Since this is an error that is likely to occur frequently (since there's no restriction on what descriptions can be), should it be handled in the onInit hook, or should this be auto handled by the library internally with perhaps a log/callback informing the user about the issue and the fix?

This issue can be re-created by running the code gen for Kubernetes API

m-Bilal avatar Apr 24 '24 13:04 m-Bilal

Commenting to say that we're running into the same thing.

vetrex avatar Jun 04 '24 14:06 vetrex

I also encountered this problem

FoSuCloud avatar Aug 31 '24 13:08 FoSuCloud

Configure prettier.requirePragma=true when generatingApi to only format files containing specific tags (called Pragma comments)

FoSuCloud avatar Sep 06 '24 14:09 FoSuCloud