Metadata-Version: 2.4
Name: Schema-First
Version: 0.4.0
Summary: OpenAPI specification validator and converter to Marshmallow schemas.
Author-email: Konstantin Fadeev <fadeev@legalact.pro>
License: MIT License
        
        Copyright (c) 2025 flask-pro
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
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: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: marshmallow>=4.0.0
Requires-Dist: PyYAML>=6.0.2
Provides-Extra: dev
Requires-Dist: bandit==1.8.6; extra == "dev"
Requires-Dist: build==1.3.0; extra == "dev"
Requires-Dist: openapi-spec-validator>=0.5.0; extra == "dev"
Requires-Dist: pre-commit==4.2.0; extra == "dev"
Requires-Dist: pytest==8.4.1; extra == "dev"
Requires-Dist: pytest-cov==6.2.1; extra == "dev"
Requires-Dist: python-dotenv==1.1.1; extra == "dev"
Requires-Dist: twine==6.1.0; extra == "dev"
Dynamic: license-file

# 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).
