swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.69k stars 1.2k forks source link

Bug: If the parsed package does not have a package name? #964

Open lifegit opened 3 years ago

lifegit commented 3 years ago

RT. image

fix: #903

lifegit commented 3 years ago

conflict: packageNameStructName(use camelCase). example: apiJsonResult. no conflict: structName. example: JsonResult.

sdghchj commented 3 years ago

What sense does it make ?

lifegit commented 3 years ago
  1. Some tools may not recognize . well .
  2. All generated models have package names . I think it's not intuitive and redundant .

image

sdghchj commented 3 years ago

As swagger 2.0 support dot in models, it is a bug of the tools you mentioned, I think.

To-echo commented 3 years ago
  1. Some tools may not recognize . well .
  2. All generated models have package names . I think it's not intuitive and redundant .

image

Excuse me, How you generate model.Tag and model.Tag 1

ubogdan commented 3 years ago

@To-echo Would you mind coming back with a code sample and explaining the issue as better you can if you need help?

To-echo commented 2 years ago

@To-echo Would you mind coming back with a code sample and explaining the issue as better you can if you need help?

Thank you for your reply, I just want to use swag to generate swagger.json and import it into YApi, but YApi does not support public struct, see: https://github.com/YMFE/yapi/issues/352, so I need to customize swap struct name generation rules, currently use URI as part of the structure name, see: https://github.com/To-echo/swag/commit/4af1b6a54c31a5c88c09feac5abbc00ce69c5ce7

ubogdan commented 2 years ago

Unfortunately, there is no way to configure struct name generation. Removing the package name from the definition will lead to struct overlap and conflicts.