2

So I am using the above two technologies to autogenerate my swagger.yaml file that then is read by Redoc and served to the clients. This is the step in my makefile:

swag init -g internal/delivery/rest/router.go --output swagger/ --outputTypes yaml

Then in my Redoc I simply reference swagger.yaml and everything works like charm.

But I have one problem. In my @description annotation for the API I have something like this:

   // @description "This is a description!"

But I want that this description actually come from a Markdown file. I know that if I manually add:

   description:
     $ref: 'description.md'

to my swagger.yaml file it works perfectly. But the thing is I can only hardcode the string in the annotations. I tried this in my annotation:

// @description file://description.md

But it literally generates this in my YAML file:

description: 'file://description.md'

How can I achieve what I want?

Helen
  • 87,344
  • 17
  • 243
  • 314
Matias Barrios
  • 4,674
  • 3
  • 22
  • 49
  • Hello, please check this document [Using markdown descriptions](https://github.com/swaggo/swag#using-markdown-descriptions), and [swag cli](https://github.com/swaggo/swag#swag-cli) `--markdownFiles value, --md value` – Trock Jun 30 '23 at 09:46
  • @Trock Yeah! I did. But that will literally embedd the markdown inside the swagger.yaml file. When there is no need for that. Redoc can read the reference just fine. I want to know how to reference it, notcopy pasting one file inside the other. – Matias Barrios Jul 01 '23 at 03:51

0 Answers0