mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(nodes): make fields that accept connection input optional in OpenAPI schema
Doing this via `BaseInvocation`'s `Config.schema_extra()` means all clients get an accurate OpenAPI schema. Shifts the responsibility of correct types to the backend, where previously it was on the client.
This commit is contained in:
parent
496a2db15c
commit
6e1ddb671e
@ -464,6 +464,16 @@ class BaseInvocation(ABC, BaseModel):
|
||||
schema["required"] = list()
|
||||
schema["required"].extend(["type", "id"])
|
||||
|
||||
# nodes may have required fields, that can accept input from connections
|
||||
# mark them as optional in the schema
|
||||
for field_name, field in model_class.__fields__.items():
|
||||
_input = field.field_info.extra.get("input", None)
|
||||
if _input in [Input.Connection, Input.Any]:
|
||||
try:
|
||||
schema["required"].remove(field_name)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def invoke(self, context: InvocationContext) -> BaseInvocationOutput:
|
||||
"""Invoke with provided context and return outputs."""
|
||||
|
Loading…
Reference in New Issue
Block a user