Skip to main content

apispec-clear-unusable

Plugin for apispec which helps reusing the documentation on a muti-endpoint function/method.

Example with flask-restful

from apispec import APISpec
from flask import Flask, jsonify
from flask_restful import Resource, Api
from marshmallow import Schema, fields

# Create an APISpec
spec = APISpec(
    title='Random swagger Petstore',
    version='1.0.0',
    plugins=[
        'apispec.ext.flask',
        'apispec.ext.marshmallow',
        'brunoais.apispec.ext.clear_unusable',
    ],
)

# This example uses flask but it also works with other frameworks
app = Flask(__name__)
api = Api(app)

class RandomPet(Resource):

    def get(self, species=None, race=None):
        """A cute random furry animal.
        ---
        description: Get a random pet
        parameters:
            - in: path
              name: species
              type: string
              description: The species of the animal to be randomly selected
        parameters:
            - in: path
              name: race
              type: string
              description: The race of the animal to be randomly selected
        responses:
            200:
                description: A pet to be returned
                schema: PetSchema
        """
        return get_random_pet(species=species, race=race), 200


api.add_resource(RandomPet, '/pets/random', endpoint='randompet')
api.add_resource(RandomPet, '/pets/<species>/random', endpoint='randompet_species')
api.add_resource(RandomPet, '/pets/<species>/races/<race>/random', endpoint='randompet_species_race')

spec.definition('Category', schema=CategorySchema)
spec.definition('Pet', schema=PetSchema)

with app.test_request_context():
    spec.add_path(view=random_pet)

Output becomes

definitions:
	#...
parameters: {}
paths:
  /pets/random:
    get:
      description: Get a random pet
      parameters: []
      responses:
        200:
          description: A pet to be returned
          schema: {$ref: '#/definitions/Pet'}
  /pets/{species}/random:
    get:
      description: Get a random pet
      parameters:
      - {description: The species of the animal to be randomly selected, in: path,
        name: species, required: true, type: string}
      responses:
        200:
          description: A pet to be returned
          schema: {$ref: '#/definitions/Pet'}
  /pets/{species}/races/{race}/random:
    get:
      description: Get a random pet
      parameters:
      - {description: The species of the animal to be randomly selected, in: path,
        name: species, required: true, type: string}
      - {description: The race of the animal to be randomly selected, in: path, name: race,
        required: true, type: string}
      responses:
        200:
          description: A pet to be returned
          schema: {$ref: '#/definitions/Pet'}
swagger: '2.0'

Installation

pip install apispec-clear-unusable

License

This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Metadata

Release files for apispec-clear-unusable 1.0.1

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-clear-unusable 1.0.1
File Size Uploaded Provenance Actions
apispec-clear-unusable-1.0.1.tar.gz 3.6 kB Without provenance Details for apispec-clear-unusable-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for apispec-clear-unusable 1.0.1
File Interpreter ABI Platform Actions
apispec_clear_unusable-1.0.1-py3-none-any.whl Python 3 none any Details for apispec_clear_unusable-1.0.1-py3-none-any.whl

Total release size: 7.3 kB

Release files / apispec-clear-unusable-1.0.1.tar.gz

Download URL apispec-clear-unusable-1.0.1.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
68afb78ebc93299ee96798d8d87fdd805a3997e2f5aa3df4276d5cd3a44211b4
BLAKE2b-256 checksum
How to use checksums
df9c02b5b81dfad5264eefe263701c86be38756f006e10fa7c2d44c1e70fad46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / apispec_clear_unusable-1.0.1-py3-none-any.whl

Download URL apispec_clear_unusable-1.0.1-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8bf26472d0785edbed407cf05b80c06909a808e09da350af12ecd9cd8b3a89d9
BLAKE2b-256 checksum
How to use checksums
bc6624db73cae0056cb96b08fd60387e8df8c72ff5a365b07edc671df426ed88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for apispec-clear-unusable 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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