728x90
def create_openapi_response(*args):
'''
key, type, description, format_[optional]
'''
properties = {}
for arg in args:
key, type_, description = arg[:3]
format_ = arg[3] if len(arg) > 3 else None
items = arg[4] if len(arg) > 4 else None
prop = {
'type': type_,
'description': description
}
if format_:
prop['format'] = format_
if items:
prop['items'] = items
properties[key] = prop
return {
'type': 'object',
'properties': properties
}
'Python > 실험실' 카테고리의 다른 글
[Python] Schema (0) | 2024.03.13 |
---|