No project description provided
Project description
openapy
adds CI/CD capability to OpenAPI generator
Overview
Quick start
With Docker
docker run
With Installation
pip install openapy
USAGE
> openapy -h
usage: openapy [-h] [--src SRC] [--template TEMPLATE] [--all] [--version]
Additional files generator for openapi
options:
-h, --help show this help message and exit
--src SRC, -s SRC source dir path
--template TEMPLATE, -t TEMPLATE
file path of the processor template
--all, -a whether overwrite all files or not
--version, -v show version
Options
(*) means it is a required option.
- src (*): Path to the source directory that contains apis
- template: Path to the custom template file
- all: With this option, all files will be overwritten
Custom Template
Following variables with {}
brackets are available.
- IMPORTS: All of imports of the source file like
import X
,from X import Y
- ASSIGNS: All assigns of the source file like
var = "string"
- DEF:
async def
ordef
of the function - NAME: The function name
- ARGS: Arguments of the function with type annotations
- RETURN_TYPE: A type annotation for the return of the function
- COMMENT: A comment inside of the function
- BODY: A body of the function, like assign statement
- RETURN: A return statement of the function
Example
apis/user_api.py
from typing import Any, Dict, List, Optional, Union # noqa: F401
from fastapi import APIRouter
from openapi_server.model.user import User
router = APIRouter()
@router.post("/get_user", tags=["user"], summary="get user")
async def get_user(id: int) -> User:
"""This function returns a new user"""
return processor.get_user.process()
@router.post("/delete_user", tags=["user"], summary="delete user")
async def delete_user(id: int, password:str="default_password") -> bool:
"""This function deletes user and return the result"""
return processor.delete_user.process()
Custom Template: template.txt
# coding: utf-8
{IMPORTS}
def process({ARGS}) -> {RETURN_TYPE}:
# Implement me!
...
processor/get_user.py
# coding: utf-8
from typing import Any, Dict, List, Optional, Union # noqa: F401
from fastapi import APIRouter # noqa: F401
from openapi_server.model.user import User # noqa: F401
def process(id: int) -> User:
# Implement me!
...
processor/delete_user.py
# coding: utf-8
from typing import Any, Dict, List, Optional, Union # noqa: F401
from fastapi import APIRouter # noqa: F401
from openapi_server.model.user import User # noqa: F401
def process(id: int) -> User:
# Implement me!
...
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
openapy-0.2.0.tar.gz
(8.6 kB
view hashes)