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

Swagger Tutorial #96

Closed
AliNasra opened this issue May 10, 2023 · 3 comments
Closed

Swagger Tutorial #96

AliNasra opened this issue May 10, 2023 · 3 comments
Assignees
Labels
Priority: High Serious problem that could block progress. Status: In Progress Assignee is working on the issue

Comments

@AliNasra
Copy link
Contributor

AliNasra commented May 10, 2023

Problem Definition

Swagger is a sophisticated tool user Swagger-compatible APIs. We are required to hand in Swagger-style documentation in fulfillment of the Project's requirements.

Suggested Solutions

I will be investigating the simplest ways to create swagger documentation. I will be providing a written handout so team members can refer continuously to the notes with no need of holding a meeting.

@AliNasra AliNasra added Priority: Medium Standard problem priority Status: To Do The issue has been reported and is waiting for the team to action it. labels May 10, 2023
@AliNasra AliNasra self-assigned this May 10, 2023
@AliNasra AliNasra added Priority: High Serious problem that could block progress. Status: In Progress Assignee is working on the issue and removed Priority: Medium Standard problem priority Status: To Do The issue has been reported and is waiting for the team to action it. labels May 10, 2023
@AliNasra
Copy link
Contributor Author

AliNasra commented May 10, 2023

1- We will be initially installing multiple libraries
In the terminal of the IDE you are using, write the following commands one by one
pip install pyyaml
1
pip install uritemplate
2
2- Go to urls.py in the API folder
3
3- add the following line
from rest_framework.schemas import get_schema_view
4
4- Add the following line in urlpatterns
path('api_schema',get_schema_view(title = 'API Schema', description = 'API documentation'), name = 'api_schema'),
5
5- Check the documentation after running the server
Use the link http://127.0.0.1:8000/api/api_schema
7
6- Install Swagger using the command
pip install django-rest-swagger
6
7- Go to the settings.py file
In the TEMPLATES list, insert the following line into DIR os.path.join(BASE_DIR, 'templates')
8
8- Under the API directory, create a new folder. Call it templates
9- In the templates folder, create the file docs.html
11
10- Copy the code in the link "Check the third step."
11- Back to the URL.py, add the following lines in urlpatterns
from django.views.generic import TemplateView
path('docs/', TemplateView.as_view( template_name='docs.html', extra_context={'schema_url':'api_schema'}), name='swagger-ui'),
11
12- Check the documentation after running the server
Use the link http://127.0.0.1:8000/api/docs/
12

@enfurars
Copy link
Contributor

enfurars commented May 10, 2023

Well done @AliNasra. Can you also provide a wiki page and link for future references?

@AliNasra
Copy link
Contributor Author

Thanks @enfurars for the feedback. I have created the required wiki page and attached the necessary links both on the home page and in the sidebar. You can find the corresponding entry titled "Swagger Tutorial" under the research subsection in the sidebar. This concludes the task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High Serious problem that could block progress. Status: In Progress Assignee is working on the issue
Projects
None yet
Development

No branches or pull requests

2 participants