Skip to main content

DekoGen

What is it?

dekogen is simple tool to avoid big unreadable HTTP requests. It's provide ability to create requests builders and response wrappers to keep match between code and OpenAPI specs.

About

Main points:

1. Maintain compliance between code and OpenAPI spec
2. Do not describe requests and responses manually
3. Use:
request_body = Configuration() \
    .number("10") \
    .settings(Settings()
          .required_protocol("33-11-JRTF")
          .element_per_second(34)
          .related_grants("785-56-IU", "89-551-11-JRT")
          .body) \
    .body
Instead of:
request_body = {"configuration": {"number": 10,
                                  "settings": {"required_protocol": "33-11-JRTF", "element_per_second": 34,
                                               "related_grants": ["785-56-IU", "89-551-1-JRT"]}}}
4. Parse responses with autocomplete

Dependencies

inflection: 0.3.1
PyYAML: 6.0
Click: 7.1.2

See the full installation instructions for recommended and optional dependencies.

Installation

pip install dekogen

License

MIT

Discussion and Development

All contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome.

Getting started

Code generation

Via command line:

Help:
dekogen_cmd -h
Commands help:
dekogen_cmd <command from help list> -h
Sample:
dekogen_cmd generate-all-python -f ~/sample-api-specs.yaml -o ~/results

Via python code:

Read data from:
from dekogen.spec_reader import SpecReader

file_path = '/home/name/sample-api-specs.yaml'
spec_reader = SpecReader
spec_data = spec_reader.read_yaml(file_path=file_path)
Generate responses:
from dekogen.spec_codegen import PythonResponsesGenerator

output_path = '/home/name/output_dir'
py_req_generator = PythonResponsesGenerator(spec_data=spec_data, file_path=output_path)
py_req_generator.generate()

Generate requests:

from dekogen.spec_codegen import PythonRequestsGenerator

output_path = '/home/name/output_dir'
py_req_generator = PythonRequestsGenerator(spec_data=spec_data, file_path=output_path)
py_req_generator.generate()

Usage:

  1. To add autocomplete for responses just pass response.body (dict) into related Response() object initialization

    response = client.request(...)
    body = NameOfTheView(response.data)
    
  2. Create scalable and readable structures for requests using direct import of generated files and classes.

Release files for dekogen 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dekogen 0.1.2
File Size Uploaded
dekogen-0.1.2.tar.gz 6.2 kB Details

Release files / dekogen-0.1.2.tar.gz

Download URL dekogen-0.1.2.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6eff153727964104cc949aa440bd7fd434bda4d05159cf9b08d3c7ee958c787e
BLAKE2b-256 checksum
How to use checksums
f5af39b261fc312ce28795a72dcfb701da62b11456d3abe3187b83bf1b1d65e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file

0.1.1

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page