acacode / swagger-typescript-api

Generate the API Client for Fetch or Axios from an OpenAPI Specification
MIT License
3.07k stars 339 forks source link

Code generation crashes if description has `*/` substring #704

Open m-Bilal opened 2 months ago

m-Bilal commented 2 months ago

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

vetrex commented 3 weeks ago

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