swaggo / swag

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

@tag.description.markdown does not select the correct markdown file if tag is a substring of another tag #1829

Closed Kafkalasch closed 3 weeks ago

Kafkalasch commented 1 month ago

Describe the bug This is about using the @tag.description.markdown feature: It does not work properly if you use two tags, where one tag is a substring of the other by coincidence.

To Reproduce // @tag.name objects // @tag.description.markdown // @tag.name my-special-objects // @tag.description.markdown

and in the markdown dir: /markdowns/my-special-objects.md /markdowns/objects.md

If you now generate the swagger docs, you'll see that (based on how your filesystem sorts the entries) both tags: "objects" and "my-special-objects" will be described by the contents in "/markdowns/my-special-objects".md

Expected behavior Both tags are described by their specific content in their specific markdown files.

Your swag version e.g. 1.16.3

Your go version e.g. 1.22.2

Additional context This bug is caused by a broken logic in: parser.go --> getMarkdownForTag I am going to open a PR for this