genshindev / api

A fan-made Genshin Impact API for easy access to game data.
https://genshin.jmp.blue
Open Software License 3.0
702 stars 196 forks source link

Adds API documentation from Swagger #263

Closed dayvsonspacca closed 4 months ago

dayvsonspacca commented 7 months ago

The main changes include the creation of a route called /docs, not accessible through the routes / or /:type, which stores the Swagger HTML file responsible for displaying the documentation. Additionally, a new script has been created to automatically generate the swagger.yml file based on what is in the data folder, creating the endpoints.

To generate the file:

npm run gen:swagger

Simply navigate to the /docs endpoint to view the documentation.

It was necessary to disable the Content Security Policy (CSP) in Helmet so that the HTML file can request the necessary CDN files to build the documentation.

The last change was to use lint and format, which resulted in many changes in files that apparently were not formatted previously.

Important to mention that the /boss endpoint was not included in the documentation because as of the current date 02/28/2024, it is not functioning properly.

dayvsonspacca commented 4 months ago

still need all the lints to be undone?

man90es commented 4 months ago

While I generally agree that PRs should focus on one change, I'd let this formatting fix slide. It's a good change to have standardised formatting

dayvsonspacca commented 4 months ago

Now that you brought up these points, this script actually became a bit useless 🙃.

I'll be closing this PR and I'll be thinking about something simpler for this documentation with this tool that you recommended or with the scalar that I've already used and found interesting.

I will come back soon with this documentation 🤙