{"id":19508466,"url":"https://github.com/ahmetoner/fastapi-offline-swagger-ui","last_synced_at":"2025-04-26T02:33:56.855Z","repository":{"id":64179116,"uuid":"573932562","full_name":"ahmetoner/fastapi-offline-swagger-ui","owner":"ahmetoner","description":"By default FastAPI uses CDN for swagger ui assets, with this repository you can use it offline.","archived":false,"fork":false,"pushed_at":"2023-07-22T22:12:27.000Z","size":5,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T07:04:17.892Z","etag":null,"topics":["docs","fastapi","offline","python","swagger-ui"],"latest_commit_sha":null,"homepage":"https://github.com/ahmetoner/fastapi-offline-swagger-ui","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/ahmetoner.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}},"created_at":"2022-12-03T22:13:40.000Z","updated_at":"2025-02-05T10:13:47.000Z","dependencies_parsed_at":"2023-01-15T02:45:20.526Z","dependency_job_id":null,"html_url":"https://github.com/ahmetoner/fastapi-offline-swagger-ui","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetoner%2Ffastapi-offline-swagger-ui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetoner%2Ffastapi-offline-swagger-ui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetoner%2Ffastapi-offline-swagger-ui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetoner%2Ffastapi-offline-swagger-ui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmetoner","download_url":"https://codeload.github.com/ahmetoner/fastapi-offline-swagger-ui/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250922212,"owners_count":21508290,"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":["docs","fastapi","offline","python","swagger-ui"],"created_at":"2024-11-10T23:07:41.194Z","updated_at":"2025-04-26T02:33:56.599Z","avatar_url":"https://github.com/ahmetoner.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastapi Offline Swagger UI\nBy default FastAPI uses CDN for swagger ui assets (js and css files), with this repository you can use it offline. This repository aims to download CDN urls and store inside of a python module. You can easily use this downloaded assets with following examples.\n\n## Install\nYou can install this software via pip or poetry.\n\n```sh\npip3 install git+https://github.com/ahmetoner/fastapi-offline-swagger-ui\n```\n\nor pyproject.toml\n\n```sh\n\n[tool.poetry.dependencies]\n...\nfastapi-offline-swagger-ui = {git = \"https://github.com/ahmetoner/fastapi-offline-swagger-ui\"}\n\n```\n\n\n## Usage Examples\nAfter installing the module, create a python file. Copy and run following.\n```py\nfrom fastapi import FastAPI, File, UploadFile, Query, applications\nfrom fastapi.responses import StreamingResponse, RedirectResponse\nfrom fastapi.staticfiles import StaticFiles\nfrom fastapi.openapi.docs import get_swagger_ui_html\nimport fastapi_offline_swagger_ui\n\napp = FastAPI()\n\n''' This following code block necessary to switch offline cdn files via fastapi_offline_swagger_ui module\n'''\nassets_path = fastapi_offline_swagger_ui.__path__[0]\nif path.exists(assets_path + \"/swagger-ui.css\") and path.exists(assets_path + \"/swagger-ui-bundle.js\"):\n    app.mount(\"/assets\", StaticFiles(directory=assets_path), name=\"static\")\n    def swagger_monkey_patch(*args, **kwargs):\n        return get_swagger_ui_html(\n            *args,\n            **kwargs,\n            swagger_favicon_url=\"\",\n            swagger_css_url=\"/assets/swagger-ui.css\",\n            swagger_js_url=\"/assets/swagger-ui-bundle.js\",\n        )\n    applications.get_swagger_ui_html = swagger_monkey_patch\n\n```\n\n## Live Example\nAlternatively you can browse [ahmetoner/whisper-asr-webservice](https://github.com/ahmetoner/whisper-asr-webservice/) repository to see how it is implemented.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmetoner%2Ffastapi-offline-swagger-ui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmetoner%2Ffastapi-offline-swagger-ui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmetoner%2Ffastapi-offline-swagger-ui/lists"}