Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding swagger documentation #332

Closed
wants to merge 0 commits into from
Closed

Conversation

spiderxm
Copy link

Added Swagger and Redoc documentation for rest apis.

@mlodic mlodic marked this pull request as draft January 28, 2021 08:17
Copy link
Member

@mlodic mlodic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your PR!

However it is really important that you read and follow the contributions guidelines.

Also please do not delete the PR template. You should compile it. Otherwise your contributions won't be considered. Everything you need to know is written there.

@eshaan7
Copy link
Member

eshaan7 commented Jan 28, 2021

We need to make this autogenerate for every commit same way as readthedocs and host them publicly like: https://intelowl.readthedocs.io/api-docs.

How can we achieve that, @spiderxm?

@spiderxm
Copy link
Author

spiderxm commented Jan 28, 2021

We can use the command

python manage.py generateschema

This will generate open api definitions in yaml.
That can be used to make swagger documentation and serve them via different application.

@eshaan7
Copy link
Member

eshaan7 commented Jan 31, 2021

This will generate open api definitions in yaml.
That can be used to make swagger documentation and serve them via different application.

Okay so what we need to do is create a GH action (or readthedocs webhook) which builds the .yml schema and puts it into /docs/source/ which then gets rendered using sphinx openapi extension sphinx redoc extension. (see Usage section, it's pretty straightforward to use this extension).

The catch here is that this action should take place before readthedocs build gets triggered for which you should find something in readthedocs documentation.

api_app/urls.py Outdated
@@ -33,3 +56,4 @@
# Viewsets
path(r"", include(router.urls)),
]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix codefactor issue

api_app/urls.py Outdated
# Routers provide an easy way of automatically determining the URL conf.
router = routers.DefaultRouter(trailing_slash=False)
router.register(r"tags", TagViewSet)
router.register(r"jobs", JobViewSet)

# Documentation Settings
schema_view = get_schema_view(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of adding this here, we should add a new file called schemas.py and add all this docs related code there.

@spiderxm
Copy link
Author

Will look into it

@eshaan7
Copy link
Member

eshaan7 commented Feb 12, 2021

sphinx-contrib/redoc#15

@spiderxm spiderxm closed this Feb 12, 2021
@eshaan7 eshaan7 linked an issue Feb 26, 2021 that may be closed by this pull request
@eshaan7 eshaan7 mentioned this pull request Feb 26, 2021
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[docs] Proper API specs/docs using Swagger
3 participants