smizell / atomically-py

Write the smallest possible OpenAPI and generate the rest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

atomically

PyPI Tests Changelog License

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

Installation

You can use pipx to install this tool.

You can also use pip:

pip install atomically

Usage

As CLI

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.

As Python library

from atomically import Atomically

openapi = Atomically.from_file("atomically.yaml").generate()
with open("openapi.yaml", "w") as f:
    f.write(openapi.to_yaml())

Development

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

About

Write the smallest possible OpenAPI and generate the rest

License:Apache License 2.0


Languages

Language:Python 100.0%