Note
This library is for experimenting and prototyping at this point and may change considerably until it reaches version 1.0.0. Please be cautious about relying on this library at this point.
Write the smallest possible OpenAPI and generate the rest. Read more about this approach in the Atomically repository.
openapi: 3.1.0
info:
title: Example
description: Example
version: 1.0.0
x-atomically:
version: 0.1.0
stacks:
Customer:
schema:
$ref: "#/components/schemas/Customer"
filters:
- $ref: "#/components/parameters/Email"
components:
parameters:
Email:
in: query
name: email
schema:
type: string
schemas:
Customer:
type: object
properties:
name:
type: string
email:
type: string
active:
type: boolean
You can use pipx
to install this tool.
- Install pipx
- Run
pipx install atomically
You can also use pip
:
pip install atomically
Run atomically --help
to see all options.
To generate an OpenAPI from from an atomic file, run:
atomically generate path-to-atomic-file.yml
Read the Atomically repository to see how to write atomic files. Check the tests/atomic_files
directory in this repo to see examples.
from atomically import Atomically
openapi = Atomically.from_file("atomically.yaml").generate()
with open("openapi.yaml", "w") as f:
f.write(openapi.to_yaml())
To contribute to this library, first checkout the code. Then create a new virtual environment:
cd atomically
python -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest