chalice-spec-pr07


Namechalice-spec-pr07 JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/TestBoxLab/chalice-spec
SummaryChalice x APISpec x Pydantic plug-ins
upload_time2023-01-29 21:42:52
maintainer
docs_urlNone
authorJake Wood
requires_python>=3.7,<4.0
licenseMIT
keywords chalice aws apispec openapi pydantic
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # chalice-spec

[![Python package](https://github.com/TestBoxLab/chalice-spec/actions/workflows/test.yml/badge.svg)](https://github.com/TestBoxLab/chalice-spec/actions/workflows/test.yml)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

**Chalice × APISpec × Pydantic plug-ins**

Combines the power of Chalice, APISpec, and Pydantic to make AWS Chalice apps easily documented

## Installation

First, add chalice-spec:

```shell
poetry add chalice_spec
```

We consider Chalice, APISpec, and Pydantic "peer dependencies." We only include them as dev
dependencies in our codebase, and you may need to install them in yours if you haven't
already.

```shell
poetry add chalice apispec pydantic
```

## Setup

First, instantiate your APISpec object with *both* the Pydantic and Chalice plug-ins, assuming
you need the functionality of each. While the Pydantic plugin can be used alone, you currently must use
the Pydantic plugin with the Chalice plugin.

```python
app = Chalice(app_name="hello_world")
spec = APISpec(chalice_app=app,
               ...,
               plugins=[PydanticPlugin(), ChalicePlugin()])
```

If you use:
```python
ChalicePlugin(generate_default_docs=True)
```
the plugin will generate empty docs (with empty request and response schemas) for every endpoint that you've defined in your app. This can be useful as a starting point / overview while developing.

## Usage

To document your API, use your existing Pydantic models and add kwargs to Chalice decorators.

**Before:**
```python
@app.route('/', methods=["POST"])
def example():
    body = MySchema.parse_obj(app.current_request.json_body)
```

**After:**
```python
@app.route('/', methods=["POST"], docs=Docs(
    post=Operation(request=MySchema)
))
def example():
    body = MySchema.parse_obj(app.current_request.json_body)
```

If you have multiple methods supported, you may have something like:

```python
@app.route('/', methods=["POST", "PUT"],
           docs=Docs(
               post=Operation(request=MyCreateSchema, response=MyReadSchema),
               put=Operation(request=MyEditSchema, response=MyReadSchema)
           )
def example():
    # code goes here
    pass
```

### API

- [ ] TODO: this section coming soon!


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/TestBoxLab/chalice-spec",
    "name": "chalice-spec-pr07",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "Chalice,AWS,APIspec,OpenAPI,Pydantic",
    "author": "Jake Wood",
    "author_email": "jake@testbox.com",
    "download_url": "https://files.pythonhosted.org/packages/6c/6e/4a29eb4532a95af57e8300e035e77d187d6d9920d6358c02c049e6256a55/chalice_spec_pr07-0.1.5.tar.gz",
    "platform": null,
    "description": "# chalice-spec\n\n[![Python package](https://github.com/TestBoxLab/chalice-spec/actions/workflows/test.yml/badge.svg)](https://github.com/TestBoxLab/chalice-spec/actions/workflows/test.yml)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n**Chalice \u00d7 APISpec \u00d7 Pydantic plug-ins**\n\nCombines the power of Chalice, APISpec, and Pydantic to make AWS Chalice apps easily documented\n\n## Installation\n\nFirst, add chalice-spec:\n\n```shell\npoetry add chalice_spec\n```\n\nWe consider Chalice, APISpec, and Pydantic \"peer dependencies.\" We only include them as dev\ndependencies in our codebase, and you may need to install them in yours if you haven't\nalready.\n\n```shell\npoetry add chalice apispec pydantic\n```\n\n## Setup\n\nFirst, instantiate your APISpec object with *both* the Pydantic and Chalice plug-ins, assuming\nyou need the functionality of each. While the Pydantic plugin can be used alone, you currently must use\nthe Pydantic plugin with the Chalice plugin.\n\n```python\napp = Chalice(app_name=\"hello_world\")\nspec = APISpec(chalice_app=app,\n               ...,\n               plugins=[PydanticPlugin(), ChalicePlugin()])\n```\n\nIf you use:\n```python\nChalicePlugin(generate_default_docs=True)\n```\nthe plugin will generate empty docs (with empty request and response schemas) for every endpoint that you've defined in your app. This can be useful as a starting point / overview while developing.\n\n## Usage\n\nTo document your API, use your existing Pydantic models and add kwargs to Chalice decorators.\n\n**Before:**\n```python\n@app.route('/', methods=[\"POST\"])\ndef example():\n    body = MySchema.parse_obj(app.current_request.json_body)\n```\n\n**After:**\n```python\n@app.route('/', methods=[\"POST\"], docs=Docs(\n    post=Operation(request=MySchema)\n))\ndef example():\n    body = MySchema.parse_obj(app.current_request.json_body)\n```\n\nIf you have multiple methods supported, you may have something like:\n\n```python\n@app.route('/', methods=[\"POST\", \"PUT\"],\n           docs=Docs(\n               post=Operation(request=MyCreateSchema, response=MyReadSchema),\n               put=Operation(request=MyEditSchema, response=MyReadSchema)\n           )\ndef example():\n    # code goes here\n    pass\n```\n\n### API\n\n- [ ] TODO: this section coming soon!\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Chalice x APISpec x Pydantic plug-ins",
    "version": "0.1.5",
    "split_keywords": [
        "chalice",
        "aws",
        "apispec",
        "openapi",
        "pydantic"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "946cd1036c994cc6b46e45ee9d81f6b588ac7c438d2b9a9b5a3d31c0959d3738",
                "md5": "2404c1e113f72bd0787cc4e7e9256be9",
                "sha256": "df2cbadcf66535637ad60062bcd76c68b987820b1914c2756223e4560440de75"
            },
            "downloads": -1,
            "filename": "chalice_spec_pr07-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2404c1e113f72bd0787cc4e7e9256be9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 6532,
            "upload_time": "2023-01-29T21:42:50",
            "upload_time_iso_8601": "2023-01-29T21:42:50.939282Z",
            "url": "https://files.pythonhosted.org/packages/94/6c/d1036c994cc6b46e45ee9d81f6b588ac7c438d2b9a9b5a3d31c0959d3738/chalice_spec_pr07-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c6e4a29eb4532a95af57e8300e035e77d187d6d9920d6358c02c049e6256a55",
                "md5": "ff082c94fd7036f76f1e1ddefdaf657a",
                "sha256": "879b8a72afc372b162fa31dc4bdede18c3d7421df3a3837a57dd3ad86a6ebcf4"
            },
            "downloads": -1,
            "filename": "chalice_spec_pr07-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "ff082c94fd7036f76f1e1ddefdaf657a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 5354,
            "upload_time": "2023-01-29T21:42:52",
            "upload_time_iso_8601": "2023-01-29T21:42:52.579258Z",
            "url": "https://files.pythonhosted.org/packages/6c/6e/4a29eb4532a95af57e8300e035e77d187d6d9920d6358c02c049e6256a55/chalice_spec_pr07-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-29 21:42:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "TestBoxLab",
    "github_project": "chalice-spec",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "chalice-spec-pr07"
}
        
Elapsed time: 0.05200s