Skip to main content

Generate an OpenAPI specification from a Python class definition

Project description

Generate an OpenAPI specification from a Python class

PyOpenAPI produces an OpenAPI specification in JSON, YAML or HTML format with endpoint definitions extracted from member functions of a strongly-typed Python class.

Features

  • supports standard and asynchronous functions (async def)
  • maps function name prefixes such as get_ or create_ to HTTP GET, POST, PUT, DELETE, PATCH
  • handles both simple and composite types (int, str, Enum, @dataclass)
  • handles generic types (List[T], Dict[K, V], Optional[T], Union[T1, T2, T3])
  • maps Python positional-only and keyword-only arguments (of simple types) to path and query parameters, respectively
  • maps composite types to HTTP request body
  • supports user-defined routes, request and response samples with decorator @webmethod
  • extracts description text from class and function doc-strings (__doc__)
  • recognizes parameter description text given in reStructuredText doc-string format (:param name: ...)
  • converts exceptions declared in doc-strings into HTTP 4xx and 5xx responses (e.g. :raises TypeError:)
  • recursively converts composite types into JSON schemas
  • groups frequently used composite types into a separate section and re-uses them with $ref
  • displays generated OpenAPI specification in HTML with ReDoc

Examples

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

python-openapi-0.1.6.tar.gz (16.4 kB view hashes)

Uploaded Source

Built Distribution

python_openapi-0.1.6-py3-none-any.whl (18.8 kB view hashes)

Uploaded Python 3

Supported by

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