ad-on-is / adonis-autoswagger

Auto-Generate swagger docs for AdonisJS
MIT License
116 stars 38 forks source link

A way to get data in json? #57

Closed FabriceGaillard closed 6 months ago

FabriceGaillard commented 6 months ago

Hi, Is there a way to get data in json format ?

ad-on-is commented 6 months ago

Currently, not. What would be the use case?

FabriceGaillard commented 6 months ago

To parse data, to filter it depending on some conditions

ad-on-is commented 6 months ago

docs() returns a stringified YAML. You should be able convert it back into json.

FabriceGaillard commented 6 months ago

Yes, i could use a package for this, but don't you convert js to yaml in this package? It Can be interesting to add in the options the output format wanted eventually.

ad-on-is commented 6 months ago

Yes, I do convert it, and it additionally saves a swagger.yaml file, which is used in production mode.

When you run the adonisJS app in dev mode, everything works seamlessly. However, when you deploy it to production, you MUST execute node ace docs:generate command, to generate the swagger.yml file, since in production you obviously don't have all the necessary references to the *.ts files and their comments, etc.

In this case, Autoswagger would have to create two file, swagger.yaml and swagger.json, to make it production ready.

FabriceGaillard commented 6 months ago

Ok thx for the explanations. I think it could be a good option to have the choose of the output format. Autoswagger would have to create only one file depending of options defined in config/swagger.ts

ad-on-is commented 6 months ago

You're lucky I'm bored right now. AutoSwagger.json() is now implemented in version 2.14.x 😅 See the docs.

FabriceGaillard commented 6 months ago

Thx!