Skip to main content

APISpec-fromfile

Tests Status

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

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.

Metadata

Release files for APISpec-fromfile 1.0.3

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

Source distribution (sdist)

Source distribution for APISpec-fromfile 1.0.3
File Size Uploaded
APISpec-fromfile-1.0.3.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for APISpec-fromfile 1.0.3
File Interpreter ABI Platform
APISpec_fromfile-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 15.0 kB

Release files / APISpec-fromfile-1.0.3.tar.gz

Download URL APISpec-fromfile-1.0.3.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
83f9e25549c889e7937473816d37085096eec404eb8f2a8b3e26416e5b017782
BLAKE2b-256 checksum
How to use checksums
43fd530b1605ee404a661599e21923c7eaab853641f6bec6d369b5820f746160
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / APISpec_fromfile-1.0.3-py3-none-any.whl

Download URL APISpec_fromfile-1.0.3-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca2d6c047b50b9062505b73c3c91bd177eb6c62987de6c0e406262b317768cb7
BLAKE2b-256 checksum
How to use checksums
c7decd324c4d5625b5e2b737cd71500f83760f85c7dc74e7386e3a634520d243
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

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