{"id":14986695,"url":"https://github.com/ergo/pyramid_apispec","last_synced_at":"2025-07-22T08:32:02.440Z","repository":{"id":43781438,"uuid":"137122788","full_name":"ergo/pyramid_apispec","owner":"ergo","description":"Pyramid plugin for openapi spec generation (using ApiSpec)","archived":false,"fork":false,"pushed_at":"2023-06-03T02:13:25.000Z","size":98,"stargazers_count":23,"open_issues_count":2,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-13T16:50:16.235Z","etag":null,"topics":["openapi","openapi-specification","pyramid-framework","python","rest-api","restful-api","swagger"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ergo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"AUTHORS.md"}},"created_at":"2018-06-12T20:14:32.000Z","updated_at":"2023-11-21T03:21:42.000Z","dependencies_parsed_at":"2024-01-03T01:20:38.127Z","dependency_job_id":"99defa28-0816-4164-ae99-316b4c087ee7","html_url":"https://github.com/ergo/pyramid_apispec","commit_stats":{"total_commits":85,"total_committers":8,"mean_commits":10.625,"dds":"0.23529411764705888","last_synced_commit":"41c0ed4b12b3cf491c52f2f9e66e120f2637b0e6"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ergo/pyramid_apispec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergo%2Fpyramid_apispec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergo%2Fpyramid_apispec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergo%2Fpyramid_apispec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergo%2Fpyramid_apispec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ergo","download_url":"https://codeload.github.com/ergo/pyramid_apispec/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergo%2Fpyramid_apispec/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266456245,"owners_count":23931383,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["openapi","openapi-specification","pyramid-framework","python","rest-api","restful-api","swagger"],"created_at":"2024-09-24T14:13:22.217Z","updated_at":"2025-07-22T08:32:02.420Z","avatar_url":"https://github.com/ergo.png","language":"Python","funding_links":[],"categories":["RESTful API"],"sub_categories":[],"readme":"# pyramid_apispec\n\npyramid_apispec allows you to create an [OpenAPI specification file](https://swagger.io/specification/)\nusing [apispec](http://apispec.readthedocs.io/en/latest/) and an online OpenAPI explorer using the\n[Swagger UI](https://swagger.io/tools/swagger-ui/) project for your [Pyramid](https://trypyramid.com)\napplication and its [marshmallow](https://marshmallow.readthedocs.io/en/latest/) schemas.\n\n# Installation\n\n    pip install pyramid_apispec\n\n# Basic usage\n\nCheck out the demo folder and minimal application example by running:\n\n    pip install -e '.[demo]'\n    python demo/app.py\n\nYou can then visit your API explorer page at http://0.0.0.0:6543/api-explorer.\n\nOr visit [generated documentation here](https://ergo.github.io/pyramid_apispec/gh-pages)\nfor an example of the demo site.\n(please note that actual REST API is not working in GitHub pages)\n\n**Note:** The demo site is using OpenAPI/Swagger v2.0.\nOpenAPI 3.0 is supported as well, it just uses a different YAML schema so pay attention to examples online.\n\n# Example\n\nThis example is based on [apispec](https://apispec.readthedocs.io/en/latest/#example-application),\nadapted for Pyramid and `pyramid_apispec` (updated as of `apispec` v5.1.0).\n\n*This example is using OpenAPI 3.0.2*\n\n## Hinting a route and its view:\n\nAdd the OpenAPI YAML to the view docstring.\nOptionally use Marshmallow schemas to define the inputs and outputs.\n\n```python\nimport uuid\n\nfrom marshmallow import Schema, fields\nfrom pyramid.view import view_config\n\n# Optional marshmallow support\nclass CategorySchema(Schema):\n    id = fields.Int()\n    name = fields.Str(required=True)\n\nclass PetSchema(Schema):\n    categories = fields.List(fields.Nested(CategorySchema))\n    name = fields.Str()\n\n@view_config(route_name=\"random_pet\", renderer=\"json\")\ndef random_pet(request):\n    \"\"\"A cute furry animal endpoint.\n    ---\n    get:\n      description: Get a random pet\n      security:\n        - ApiKeyAuth: []\n      responses:\n        200:\n          description: Return a pet\n          content:\n            application/json:\n              schema: PetSchema\n    \"\"\"\n    # Hardcoded example data\n    pet_data = {\n        \"name\": \"sample_pet_\" + str(uuid.uuid1()),\n        \"categories\": [{\"id\": 1, \"name\": \"sample_category\"}],\n    }\n    return PetSchema().dump(pet_data)\n```\n\nFor more details on how to document the API, see the [OpenAPI specification](https://swagger.io/specification/).\n\n## Rendering the spec as JSON response:\n\n```python\nfrom apispec import APISpec\nfrom apispec.ext.marshmallow import MarshmallowPlugin\nfrom pyramid.view import view_config\nfrom pyramid_apispec.helpers import add_pyramid_paths\n\n@view_config(route_name=\"openapi_spec\", renderer=\"json\")\ndef api_spec(request):\n    \"\"\"View to generate the OpenAPI JSON output.\"\"\"\n    spec = APISpec(\n        title=\"Some API\",\n        version=\"1.0.0\",\n        openapi_version=\"3.0.2\",\n        plugins=[MarshmallowPlugin()],\n    )\n\n    # Optional security scheme support\n    api_key_scheme = {\"type\": \"apiKey\", \"in\": \"header\", \"name\": \"X-API-Key\"}\n    spec.components.security_scheme(\"ApiKeyAuth\", api_key_scheme)\n\n    # Optionally register Marshmallow schema for more flexibility\n    spec.components.schema(\"Pet\", schema=PetSchema)\n\n    # inspect the `random_pet` route and generate operations from docstring\n    add_pyramid_paths(spec, 'random_pet', request=request)\n\n    return spec.to_dict()\n```\n\n## Adding the API Explorer View\n\nTo complement the specification file generation, this package can also provide an API explorer\nfor your application's API via the Swagger UI project:\n\n```python\nconfig.include(\"pyramid_apispec.views\")\nconfig.add_route(\"openapi_spec\", \"/openapi.json\")\nconfig.pyramid_apispec_add_explorer(spec_route_name=\"openapi_spec\")\n```\n\nBy default you need to pass the route name of the view that serves the OpenAPI\nspecification in your application. If needed you can specify a Pyramid `permission` or\ncustom callable (`script_generator` argument) to override the default JavaScript\nconfiguration of Swagger UI.\n\nThe default URL for the explorer is `/api-explorer`. This setting is controlled\nvia the `explorer_route_path` argument - the route is registered as `pyramid_apispec.api_explorer_path`.\n\n# Running tests\n\n    pip install -e '.[dev]'\n    tox\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fergo%2Fpyramid_apispec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fergo%2Fpyramid_apispec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fergo%2Fpyramid_apispec/lists"}