Skip to main content

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(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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

APISpec-fromfile-1.0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

APISpec_fromfile-1.0.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file APISpec-fromfile-1.0.1.tar.gz.

File metadata

  • Download URL: APISpec-fromfile-1.0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for APISpec-fromfile-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e09a7e0623be7fe65363a5378fdf183dcaefc9193cbc5f4aeb3aacc6768411f3
MD5 1775a6fe0af0c4a7aa3013e1bb4270d8
BLAKE2b-256 be563e9ddf66c52073208d5866da5a959e47d3e86cbc526517d6df15a5a239e1

See more details on using hashes here.

File details

Details for the file APISpec_fromfile-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: APISpec_fromfile-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for APISpec_fromfile-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6bee1a5ba5969eb29fab0983d236da714b95ca93271d28283daf3447d0d209ec
MD5 a99ca5c99fff15f3a87bd67f1ce8e13d
BLAKE2b-256 5369ba85bbad51aab9d89cd7ecafdab4a1cce318be37d948a1fba67d8cd2b46c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page