Metadata-Version: 2.4
Name: Schema-First
Version: 0.14.4
Summary: OpenAPI specification validator and converter to Marshmallow schemas.
Author-email: Konstantin Fadeev <jredkiy@yandex.ru>
License-Expression: LGPL-2.1-only
Project-URL: changelog, https://github.com/flask-pro/schema-first/blob/master/CHANGES.md
Project-URL: repository, https://github.com/flask-pro/schema-first
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.14
Description-Content-Type: text/markdown
Requires-Dist: marshmallow>=4.3.0
Requires-Dist: PyYAML>=6.0.3
Provides-Extra: dev
Requires-Dist: bandit>=1.9.3; extra == "dev"
Requires-Dist: build>=1.4.0; extra == "dev"
Requires-Dist: openapi-spec-validator>=0.7.1; extra == "dev"
Requires-Dist: pre-commit>=4.5.1; extra == "dev"
Requires-Dist: pytest>=9.1.1; extra == "dev"
Requires-Dist: pytest-cov>=7.0.0; extra == "dev"
Requires-Dist: python-dotenv>=1.2.1; extra == "dev"
Requires-Dist: twine==6.2.0; extra == "dev"

# Schema-First

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

<!--TOC-->

- [Schema-First](#schema-first)
  - [Features](#features)
  - [Installation](#installation)
  - [Example](#example)
  - [Additional documentation](#additional-documentation)

<!--TOC-->

## 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`:

```shell
$ pip install -U schema_first
```

## Example

Create specification - `openapi.yaml`:
```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`:
```python
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

* [OpenAPI Documentation](https://swagger.io/specification/).
* [OpenAPI on GitHub](https://github.com/OAI/OpenAPI-Specification).
* [JSON Schema Documentation](https://json-schema.org/specification.html).
