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

Run Swagger UI so visitors can explore our APIs #5914

Closed
3 of 7 tasks
cclauss opened this issue Nov 28, 2021 · 20 comments · Fixed by #6018
Closed
3 of 7 tasks

Run Swagger UI so visitors can explore our APIs #5914

cclauss opened this issue Nov 28, 2021 · 20 comments · Fixed by #6018
Assignees
Labels
Lead: @jimchamp Issues overseen by Jim (Front-end Lead, BookNotes) [managed] Priority: 3 Issues that we can consider at our leisure. [managed] Theme: Public APIs Issues related to APIs accessible to external parties. [managed]
Milestone

Comments

@cclauss
Copy link
Contributor

cclauss commented Nov 28, 2021

Many people would like to have better, more interactive documentation on Open Library APIs.

Describe the problem that you'd like solved

Run https://github.com/swagger-api/swagger-ui on an Open Library server so that visitors can better understand and try out our APIs. #5898 could generate the required openapi.json file so our Swagger UI was kept up-to-date as our APIs change. The try it out feature can make our APIs come alive even for nontechnical visitors.

Screenshot 2021-11-22 at 16 39 59

Proposal & Constraints

Additional context

Stakeholders

@cclauss cclauss added Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Needs: Lead Theme: Public APIs Issues related to APIs accessible to external parties. [managed] labels Nov 28, 2021
@mekarpeles mekarpeles added Priority: 3 Issues that we can consider at our leisure. [managed] Lead: @jimchamp Issues overseen by Jim (Front-end Lead, BookNotes) [managed] and removed Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Needs: Lead labels Nov 29, 2021
@cclauss
Copy link
Contributor Author

cclauss commented Dec 1, 2021

@RayBB @jimman2003 Would one of you be willing to lead this effort?

@RayBB
Copy link
Collaborator

RayBB commented Dec 1, 2021

@cclauss what exactly needs to be checked here?

@cclauss
Copy link
Contributor Author

cclauss commented Dec 2, 2021

I added a todo list above.

@Dnouv
Copy link
Contributor

Dnouv commented Dec 13, 2021

@cclauss I would like to contribute to this issue, please let me know if it's still available or not?

@cclauss
Copy link
Contributor Author

cclauss commented Dec 13, 2021

That would be great!! I discussed this briefly with @cdrini and he said that the best would be if we could take the JavaScript and CSS bits and host the Swagger UI page on our own web server. Here is an effort to do that with FastAPI:
https://fastapi.tiangolo.com/advanced/extending-openapi/#self-hosting-javascript-and-css-for-docs

@Dnouv
Copy link
Contributor

Dnouv commented Dec 13, 2021

Thank you! I will go through the FastAPI docs.

@Dnouv
Copy link
Contributor

Dnouv commented Dec 19, 2021

@cclauss, I'm trying to access the API page on the development version, but it returns 404, so where and how can I access the API page on the dev version or, more specifically, the route of /developer/API page in the repo? Could you please help me out with this?
Thank you!

@cclauss
Copy link
Contributor Author

cclauss commented Dec 19, 2021

https://openlibrary.org/developers -- log in and click the Edit button in the upper right of the page.
https://openlibrary.org/developers/api -- log in and click the Edit button in the upper right of the page.

@Dnouv
Copy link
Contributor

Dnouv commented Dec 20, 2021

Thank you so much, @cclauss, for clearing my questions. So, if I got it correct, there is no template defined for the /developers/api page, and we need to create one template that integrates the Swagger-UI.
And I looked at the steps of adding/integrating the SwaggerUI in the OL, and it requires a few JS files.

swagger-ui.css
swagger-ui-bundle.js
swagger-ui-standalone-preset.js

So, this JS files should be added in openlibrary/plugins/openlibrary/js or do we prefer adding swagger-ui npm package?

Please correct me if I missed something.

@cclauss
Copy link
Contributor Author

cclauss commented Dec 20, 2021

You will need to work with @jimchamp or @cdrini or others on that because I know Python but not all that JS/CSS stuff.

@Dnouv
Copy link
Contributor

Dnouv commented Dec 23, 2021

Thank you so much, @cclauss, for clearing my questions. So, if I got it correct, there is no template defined for the /developers/api page, and we need to create one template that integrates the Swagger-UI. And I looked at the steps of adding/integrating the SwaggerUI in the OL, and it requires a few JS files.

swagger-ui.css
swagger-ui-bundle.js
swagger-ui-standalone-preset.js

So, this JS files should be added in openlibrary/plugins/openlibrary/js or do we prefer adding swagger-ui npm package?

Please correct me if I missed something.

@cdrini or @jimchamp, could you please help me with a few questions.
Thank you!

@Dnouv
Copy link
Contributor

Dnouv commented Dec 28, 2021

@cclauss cdrini and jimchamp were busy, so I went ahead and used Unpkg in place of js files or npm module, I tried integrating the Swagger UI with the openapi.json, provided in the task list above; here is a pic of the page,

image

Feedbacks are most welcomed. Thank you!

@Dnouv
Copy link
Contributor

Dnouv commented Dec 28, 2021

@cclauss, I'm trying to commit the changes, but there is an unknown error, could you please help me out with this

gitpod /workspace/openlibrary $ git commit -m "Add swagger html and openapi"
`pre-commit` not found.  Did you forget to activate your virtualenv?

@jimman2003
Copy link
Contributor

Hey, so openlibrary uses pre-commit , a python program to run some checks over the code, please install it through the pip package installer with: pip install pre-commit

@Dnouv
Copy link
Contributor

Dnouv commented Dec 28, 2021

Thank you so much for the help @jimman2003, I tried installing pre-commit but there was a new error

gitpod /workspace/openlibrary $ pip install pre-commit
pyenv: version `3.9.4' is not installed (set by /workspace/openlibrary/.python-version)

@jimman2003
Copy link
Contributor

let me test also through gitpod :)

@Dnouv
Copy link
Contributor

Dnouv commented Dec 28, 2021

@jimman2003, thank you for your help! I resolved the issue.

@jimman2003
Copy link
Contributor

Out of curiosity, how @Dnouv ?

@Dnouv
Copy link
Contributor

Dnouv commented Dec 28, 2021

I got it fixed after a few installations,

pyenv install 3.9.4
##Fixed pyenv: version `3.9.4' is not installed (set by /workspace/openlibrary/.python-version)

##Then your mentioned command
pip install pre-commit

And the changes got committed.
Once again, thank you!

@Dnouv
Copy link
Contributor

Dnouv commented Jan 18, 2022

@cclauss, could you please let me know the further tasks? I've opened a PR integrating Swagger UI and am still awaiting a review.
Feel free to comment. Thank you!

@mekarpeles mekarpeles added this to the Next (proposed) milestone Dec 12, 2022
@mekarpeles mekarpeles modified the milestones: Next (proposed), 2023 Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lead: @jimchamp Issues overseen by Jim (Front-end Lead, BookNotes) [managed] Priority: 3 Issues that we can consider at our leisure. [managed] Theme: Public APIs Issues related to APIs accessible to external parties. [managed]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants