Set model type to const value in openapi schema, add model format enums to model schema(as they not not referenced in case of Literal definition)

This commit is contained in:
Sergey Borisov
2023-06-20 03:44:58 +03:00
committed by psychedelicious
parent da566b59e8
commit 21245a0fb2
2 changed files with 71 additions and 16 deletions

View File

@ -120,6 +120,22 @@ def custom_openapi():
invoker_schema["output"] = outputs_ref
from invokeai.backend.model_management.models import get_model_config_enums
for model_config_format_enum in set(get_model_config_enums()):
name = model_config_format_enum.__qualname__
if name in openapi_schema["components"]["schemas"]:
# print(f"Config with name {name} already defined")
continue
# "BaseModelType":{"title":"BaseModelType","description":"An enumeration.","enum":["sd-1","sd-2"],"type":"string"}
openapi_schema["components"]["schemas"][name] = dict(
title=name,
description="An enumeration.",
type="string",
enum=list(v.value for v in model_config_format_enum),
)
app.openapi_schema = openapi_schema
return app.openapi_schema