Skip to main content

OpenAPI specification validator and converter to Marshmallow schemas.

Project description

Schema-First

Validate and convert OpenAPI specification via Marshmallow schemas to Marshmallow schemas.

Features

  • OpenAPI specification validate.
  • Convert OpenAPI schemas to Marshmallow schemas.

Installation

Recommended using the latest version of Python. Schema-First supports Python 3.14 and newer.

Install and update using pip:

$ pip install -U schema_first

Example

Create specification - openapi.yaml:

openapi: 3.1.1
info:
    title: Example API for testing Flask-First
    version: 1.0.1
paths:
    /endpoint:
        get:
            operationId: endpoint
            responses:
                '200':
                    content:
                        application/json:
                            schema:
                                properties:
                                    message:
                                        type: string
                                type: object
                    description: OK

Create script - main.py:

from pathlib import Path
from pprint import pprint

from schema_first.specification import Specification

spec_file = Path('openapi.yaml')
spec = Specification(spec_file)
spec.load()

pprint(spec.reassembly_spec)
print(
    'Marshmallow schema generated from OpenAPI schema',
    spec.reassembly_spec['paths']['/endpoint']['get']['responses']['200']['content'][
        'application/json'
    ]['schema'],
)

More example see to ./example folder.

Additional documentation

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

schema_first-0.6.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file schema_first-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: schema_first-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for schema_first-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ddf8c0d0ccc5ba13026c62fed11a83ed8547c13876e77065bb6ce0726cf20daa
MD5 9a09b4cf10b5e905de1f52dd9ea7dd70
BLAKE2b-256 c10aa17ab4da9ef2ea8676df5ca4a7c339879ea7f15b5902b8cf839cfe4c1e26

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