{"id":15091348,"url":"https://github.com/hasansezertasan/openapipages","last_synced_at":"2025-04-12T06:18:42.898Z","repository":{"id":220674938,"uuid":"752251314","full_name":"hasansezertasan/openapipages","owner":"hasansezertasan","description":"Totally Pythonic, OpenAPI Based customizable documentation pages for SwaggerUI, ReDoc, RapiDoc, Elements, Scalar.","archived":false,"fork":false,"pushed_at":"2025-04-07T17:45:53.000Z","size":62,"stargazers_count":20,"open_issues_count":4,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T06:18:33.950Z","etag":null,"topics":["fastapi","flask","litestar","openapi","openapi-specification","openapidoc","pypi-package","pypi-reserved","used-hatch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hasansezertasan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-03T13:38:47.000Z","updated_at":"2025-03-31T20:14:20.000Z","dependencies_parsed_at":"2024-02-09T19:29:01.390Z","dependency_job_id":"a609b957-9000-4e8e-9f16-732dd8b6d049","html_url":"https://github.com/hasansezertasan/openapipages","commit_stats":{"total_commits":35,"total_committers":6,"mean_commits":5.833333333333333,"dds":0.6571428571428571,"last_synced_commit":"82f18f1e219a73090b32f5465880a9ba94b93e14"},"previous_names":["hasansezertasan/openapidoc"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasansezertasan%2Fopenapipages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasansezertasan%2Fopenapipages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasansezertasan%2Fopenapipages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasansezertasan%2Fopenapipages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hasansezertasan","download_url":"https://codeload.github.com/hasansezertasan/openapipages/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525141,"owners_count":21118620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","flask","litestar","openapi","openapi-specification","openapidoc","pypi-package","pypi-reserved","used-hatch"],"created_at":"2024-09-25T10:40:32.255Z","updated_at":"2025-04-12T06:18:42.869Z","avatar_url":"https://github.com/hasansezertasan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Open API Pages\n\n[![PyPI - Version](https://img.shields.io/pypi/v/openapipages.svg)](https://pypi.org/project/openapipages)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/openapipages.svg)](https://pypi.org/project/openapipages)\n[![License](https://img.shields.io/github/license/hasansezertasan/openapipages.svg)](https://github.com/hasansezertasan/openapipages/blob/main/LICENSE)\n[![Latest Commit](https://img.shields.io/github/last-commit/hasansezertasan/openapipages)](https://github.com/hasansezertasan/openapipages)\n\n[![Downloads](https://pepy.tech/badge/openapipages)](https://pepy.tech/project/openapipages)\n[![Downloads/Month](https://pepy.tech/badge/openapipages/month)](https://pepy.tech/project/openapipages)\n[![Downloads/Week](https://pepy.tech/badge/openapipages/week)](https://pepy.tech/project/openapipages)\n\nTotally Pythonic, OpenAPI Based customizable documentation pages for [SwaggerUI], [ReDoc], [RapiDoc], [Elements], [Scalar].\n\n\u003e Keep in mind, that this package doesn't generate [OpenAPI] Spec, it just renders the pages with the given configuration.\n\n---\n\n## Table of Contents\n\n- [Open API Pages](#open-api-pages)\n  - [Table of Contents](#table-of-contents)\n  - [Features](#features)\n    - [Progress](#progress)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [FastAPI](#fastapi)\n    - [Litestar](#litestar)\n  - [Motivation](#motivation)\n    - [Developer Experience](#developer-experience)\n    - [Configuration](#configuration)\n    - [Alternatives](#alternatives)\n    - [Standardisation](#standardisation)\n  - [See Also](#see-also)\n    - [Projects](#projects)\n    - [Issues, PRs, and Discussions](#issues-prs-and-discussions)\n  - [Author](#author)\n  - [Disclaimer](#disclaimer)\n  - [License](#license)\n\n## Features\n\n\u003e Gimme an OpenAPI Spec, leave the rest to me...\n\n- Framework agnostic.\n- Zero dependencies, just Python standard library.\n- Fully typed.\n- Highly extensible.\n\n### Progress\n\n| Documentation | Page               | Config             |\n| ------------- | ------------------ | ------------------ |\n| [SwaggerUI]   | :white_check_mark: | :heavy_check_mark: |\n| [ReDoc]       | :white_check_mark: | :heavy_check_mark: |\n| [RapiDoc]     | :white_check_mark: | :heavy_check_mark: |\n| [Elements]    | :white_check_mark: | :heavy_check_mark: |\n| [Scalar]      | :white_check_mark: | :heavy_check_mark: |\n\nEmoji Key:\n\n| Emoji                 | Meaning     |\n| --------------------- | ----------- |\n| :white_check_mark:    | Ready       |\n| :heavy_check_mark:    | Partially   |\n| :x:                   | Failed      |\n| :construction:        | In Progress |\n| :white_square_button: | Pending     |\n| :warning:             | Not sure    |\n\n## Installation\n\n```console\npip install openapipages\n```\n\n## Usage\n\nI know it looks a bit boilerplate but it's all straight-forward. The `.render()` method returns the HTML as a string. Thanks to this design, you can extend and configure the pages as you wish (e.g. add extra logic to restrict access to the page).\n\n### FastAPI\n\n\u003e The `include_in_schema` parameter is set to `False` in each endpoint to avoid including these endpoints in the OpenAPI Spec.\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi.responses import HTMLResponse\nfrom openapipages import Elements, RapiDoc, ReDoc, Scalar, SwaggerUI\n\n# Disable the built-in /redoc page so we can make a custom one.\napp = FastAPI(redoc_url=None)\n\n\n@app.get(\"/\")\ndef root() -\u003e dict[str, str]:\n    return {\"Hello\": \"World\"}\n\n\n@app.get(\"/swaggerui\", response_class=HTMLResponse, include_in_schema=False)\ndef get_swaggerui() -\u003e str:\n    return SwaggerUI(title=\"Swagger UI\").render()\n\n\n@app.get(\"/redoc\", response_class=HTMLResponse, include_in_schema=False)\ndef get_redoc() -\u003e str:\n    return ReDoc(title=\"ReDoc\").render()\n\n\n@app.get(\"/scalar\", response_class=HTMLResponse, include_in_schema=False)\ndef get_scalar() -\u003e str:\n    return Scalar(title=\"Scalar\").render()\n\n\n@app.get(\"/elements\", response_class=HTMLResponse, include_in_schema=False)\ndef get_elements() -\u003e str:\n    return Elements(title=\"Elements\").render()\n\n\n@app.get(\"/rapidoc\", response_class=HTMLResponse, include_in_schema=False)\ndef get_rapidoc() -\u003e str:\n    return RapiDoc(title=\"RapiDoc\").render()\n\n```\n\n### Litestar\n\n\u003e The `include_in_schema` parameter is set to `False` in each endpoint to avoid including these endpoints in the OpenAPI Spec.\n\n```python\nfrom litestar import Litestar, MediaType, get\nfrom openapipages import Elements, RapiDoc, ReDoc, Scalar, SwaggerUI\n\nopenapi_url = \"/schema/openapi.json\"\n\n\n@get(\"/\")\ndef root() -\u003e dict[str, str]:\n    return {\"Hello\": \"World\"}\n\n\n@get(\"/swaggerui\", media_type=MediaType.HTML, include_in_schema=False)\ndef get_swaggerui() -\u003e str:\n    return SwaggerUI(title=\"Swagger UI\", openapi_url=openapi_url).render()\n\n\n@get(\"/redoc\", media_type=MediaType.HTML, include_in_schema=False)\ndef get_redoc() -\u003e str:\n    return ReDoc(title=\"ReDoc\", openapi_url=openapi_url).render()\n\n\n@get(\"/scalar\", media_type=MediaType.HTML, include_in_schema=False)\ndef get_scalar() -\u003e str:\n    return Scalar(title=\"Scalar\", openapi_url=openapi_url).render()\n\n\n@get(\"/elements\", media_type=MediaType.HTML, include_in_schema=False)\ndef get_elements() -\u003e str:\n    return Elements(title=\"Elements\", openapi_url=openapi_url).render()\n\n\n@get(\"/rapidoc\", media_type=MediaType.HTML, include_in_schema=False)\ndef get_rapidoc() -\u003e str:\n    return RapiDoc(title=\"RapiDoc\", openapi_url=openapi_url).render()\n\n\napp = Litestar([root, get_swaggerui, get_redoc, get_scalar, get_elements, get_rapidoc])\n\n```\n\n## Motivation\n\nTL;DR - I don't want to copy and paste it again...\n\n### Developer Experience\n\nSeveral API Documentation tools are ready to use at your fingertips with a standard interface.\n\nNo more copying and pasting the same thing from one project to another. Import the package and use it!\n\n### Configuration\n\nHere is a pull request made to the [FastAPI] repo. This was the point I understood the configuration was limited and it wouldn't change...\n\n- [Allow passing ui parameters to redoc html by adriantre · Pull Request #10437 · tangelo/fastapi](https://github.com/tiangolo/fastapi/pull/10437)\n\nAlso, the author's answer to this PR shows that we won't be seeing more alternative documentation tools in the future.\n\n### Alternatives\n\nHere is another pull request made to the [FastAPI] repo. It brings [Scalar] support, but it's not approved/merged yet and I think it will stay that way thanks to the previous PR.\n\n- [feat: add scalar integration (additional alternative to Swagger UI/Redoc) by marclave · Pull Request #10674 · tiangolo/fastapi](https://github.com/tiangolo/fastapi/pull/10674)\n\n### Standardisation\n\n\u003e A standard interface for many API Documentation Interfaces with configuration features.\n\nLately, OpenAPI Spec-based Documentation tools have become popular in the Python community. We see a lot of projects ([FastAPI], [Litestar], [APISpec], [flasgger], [SpecTree], [Connexion], etc) offering support for OpenAPI Specification out of the box.\n\n[Litestar] has support for [SwaggerUI], [ReDoc], [RapiDoc], and [Elements] and [FastAPI] has support for [SwaggerUI], and [ReDoc] but what is next? Will the next one be enough?\n\nThey all have one thing in common, some HTML (as Python string or a file) templated with the given configuration.\n\nDo you see where I am going?\n\nI want `openapipages` to be SQLAlchemy of OpenAPI Spec-based Documentation tools.\n\nOne interface for many! And of course Framework agnostic... So you can use it in your [FastAPI], [Litestar] projects, or any other project that generates OpenAPI specifications.\n\n## See Also\n\n### Projects\n\n- [kemingy/defspec: Create the OpenAPI spec and document from dataclass, attrs, etc.](https://github.com/kemingy/defspec/)\n- [spec-first/swagger_ui_bundle: bundled swagger-ui pip package](https://github.com/spec-first/swagger_ui_bundle)\n- [spec-first/connexion: Connexion is a modern Python web framework that makes spec-first and api-first development easy.][Connexion]\n- [sveint/flask-swagger-ui: Swagger UI blueprint for flask](https://github.com/sveint/flask-swagger-ui)\n- [flasgger/flasgger: Easy OpenAPI specs and Swagger UI for your Flask API][flasgger]\n- [marshmallow-code/apispec: A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)..][APISpec]\n- [jmcarp/flask-apispec][Flask-apispec]\n\n### Issues, PRs, and Discussions\n\n- [[Question] Is it possible to load the Swagger UI offline? · Issue #261 · 0b01001001/spectree](https://github.com/0b01001001/spectree/issues/261)\n- [Swagger with hosted files does not work after upgrade · tiangolo/fastapi · Discussion #10426](https://github.com/tiangolo/fastapi/discussions/10426)\n- [♻️ Generate cleaner Swagger HTML by s-rigaud · Pull Request #11072 · tiangolo/fastapi](https://github.com/tiangolo/fastapi/pull/11072)\n\n## Author\n\n- [Hasan Sezer Tasan](https://www.github.com/hasansezertasan), It's me :wave:\n\n## Disclaimer\n\n[FastAPI] and [Litestar] projects and the two pull requests mentioned above inspired me to create this package.\n\n## License\n\n`openapipages` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n\n\u003c!-- Links --\u003e\n[OpenAPI]: https://github.com/OAI/OpenAPI-Specification\n\u003c!-- Python Projects --\u003e\n[FastAPI]: https://github.com/tiangolo/fastapi\n[Litestar]: https://github.com/litestar-org/litestar\n[SpecTree]: https://github.com/0b01001001/spectree\n[flasgger]: https://github.com/flasgger/flasgger\n[Connexion]: https://github.com/spec-first/connexion\n[APISpec]: https://github.com/marshmallow-code/apispec\n[Flask-apispec]: https://github.com/jmcarp/flask-apispec\n\u003c!-- API Documentation Tools --\u003e\n[Scalar]: https://github.com/scalar/scalar\n[Elements]: https://github.com/stoplightio/elements\n[RapiDoc]: https://github.com/rapi-doc/RapiDoc\n[ReDoc]: https://github.com/Redocly/redoc\n[SwaggerUI]: https://github.com/swagger-api/swagger-ui\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhasansezertasan%2Fopenapipages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhasansezertasan%2Fopenapipages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhasansezertasan%2Fopenapipages/lists"}