APISpec plugin to import OpenAPI specifications from a file instead of putting YAML into docstrings
Project description
APISpec-fromfile
APISpec plugin to import OpenAPI specifications from a file instead of putting YAML into docstrings.
Installation
pip install apispec-fromfile
Usage
Create a YAML file my/spec/file.yml
:
---
get:
summary: Hello
operationId: hello
responses:
200:
content:
application/json:
schema:
type: string
Then, use APISpec in your Python code:
from apispec import APISpec
from apispec_fromfile import FromFilePlugin
from apispec_fromfile import from_file
# Create an APISpec
spec = APISpec(
title="Swagger Petstore",
version="1.0.0",
openapi_version="3.0.3",
plugins=[
FromFilePlugin("resource"),
],
)
# Create an endpoint
@from_file("my/spec/file.yml")
def hello():
return {"hello"}
# Register entities and paths
spec.path("/hello", resource=hello)
Related links
- Contribute: https://github.com/ovh/python-apispec-fromfile/blob/master/CONTRIBUTING.md
- Report bugs: https://github.com/ovh/python-apispec-fromfile/issues
- Get latest version: https://pypi.org/project/apispec-fromfile
License
Copyright 2020 OVH SAS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file APISpec-fromfile-1.0.3.tar.gz
.
File metadata
- Download URL: APISpec-fromfile-1.0.3.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83f9e25549c889e7937473816d37085096eec404eb8f2a8b3e26416e5b017782 |
|
MD5 | bafdbc8ddb50959507b50dcc3e8f2e9e |
|
BLAKE2b-256 | 43fd530b1605ee404a661599e21923c7eaab853641f6bec6d369b5820f746160 |
File details
Details for the file APISpec_fromfile-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: APISpec_fromfile-1.0.3-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca2d6c047b50b9062505b73c3c91bd177eb6c62987de6c0e406262b317768cb7 |
|
MD5 | cf1fed3997c25a16f35b2bf85a2dcfe0 |
|
BLAKE2b-256 | c7decd324c4d5625b5e2b737cd71500f83760f85c7dc74e7386e3a634520d243 |