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.2.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.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: APISpec-fromfile-1.0.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for APISpec-fromfile-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ea922d9cc2a23ae977f1c0d0d8e6ab5232395b729316e46b18bbf66238e8c254
MD5 11ac2f56c7e3443d2ca79b35bbec681f
BLAKE2b-256 9d246c6e67034953dad8be30ea522e754fa1e8849f2bf8164e469f23fa1619e1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: APISpec_fromfile-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for APISpec_fromfile-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fa39175eb3ae888066a2f2fd42e00e870c87c30420f07bad4ce96823aa581606
MD5 c54781b44edd45cc5d67e6ed4ad20085
BLAKE2b-256 e914b67d3d6ce496af12b95ce77a177287455949089c05b42f140dc2de1b3127

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