Skip to main content
Pyramid Swagger Specifier
===============================

version number: 0.0.8
author: Marcel Sander

Overview
--------

Defines APIs, generates a Swagger specification, and validates inputs

Installation / Usage
--------------------

To install use pip:

$ pip install pyramid_swagger_spec


Or clone the repo:

$ git clone https://github.com/ActiDoo/pyramid_swagger_spec.git
$ python setup.py install

Setup the view-deriver and RouteRegistry in your configuration (\_\_init\_\_.py) by including

```python
config.include('pyramid_swagger_spec')
```

Create an API namespace, e.g. in your routes.py:

```python
from pyramid_swagger_spec import create_api_namespace
api_route = create_api_namespace(namespace="api")
```

Setup the views. They return the swagger spec as json at /{namespace}/_swagger and as HTML at /{namespace}/_swagger.html.

```python
from pyramid_swagger_spec.swagger import create_swagger_view
create_swagger_view(config, namespace="api", title="Server Api", version="0.1")
```

To specify API calls:

```python
import pyramid_swagger_spec.swagger as sw
# If you use traversal, the traversal hierarchy has to match the subpath (i.e. /api/echo must return an EchoRessource instance)
# If you don't use traversal, do not pass a context and a name attribute
from myproject.ressources import EchoRessource
from myproject.routes import api_route


@api_route(path="/echo/{x}", request_method="GET", name="test", context=EchoRessource, renderer='json', api=sw.api(
tag="default",
operation_id="echo_test",
summary="echos the input",
parameters=[
sw.path_parameter("x", sw.Types.number),
sw.query_parameter("o", sw.Types.number)
],
responses={
200: sw.response(schema={
"status": sw.property(sw.Types.string)
})
}
))
def echo_test_view(request, *args, **kw):
return {
'x': request.validated_params.path["x"],
'o': request.validated_params.query["o"],
'status': "ok"
}
```

Contributing
------------

Everything is welcome. For example tests, output validation, etc.

Metadata

Release files for pyramid_swagger_spec 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyramid_swagger_spec 0.0.11
File Size Uploaded Provenance Actions
pyramid_swagger_spec-0.0.11.tar.gz 8.0 kB Without provenance Details for pyramid_swagger_spec-0.0.11.tar.gz

Release files / pyramid_swagger_spec-0.0.11.tar.gz

Download URL pyramid_swagger_spec-0.0.11.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
91c9a7c065cef07754426491caee698723ec33f782dd1dd4dc933050c463643e
BLAKE2b-256 checksum
How to use checksums
c58748ee792742c7e4259f3762011757138bc6b3958c3b0cd49e6894d7b2ce82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyramid_swagger_spec 0.0.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page