mirror of
https://github.com/langgenius/dify.git
synced 2026-04-27 11:06:46 +08:00
feat: enhance datasource credential and OAuth schema serialization
This commit is contained in:
parent
ef8d941633
commit
529eca70bc
@ -203,7 +203,7 @@ class DatasourceAuthListApi(Resource):
|
|||||||
datasources = datasource_provider_service.get_all_datasource_credentials(
|
datasources = datasource_provider_service.get_all_datasource_credentials(
|
||||||
tenant_id=current_user.current_tenant_id
|
tenant_id=current_user.current_tenant_id
|
||||||
)
|
)
|
||||||
return {"result": datasources}, 200
|
return {"result": jsonable_encoder(datasources)}, 200
|
||||||
|
|
||||||
class DatasourceAuthOauthCustomClient(Resource):
|
class DatasourceAuthOauthCustomClient(Resource):
|
||||||
@setup_required
|
@setup_required
|
||||||
|
|||||||
@ -416,53 +416,17 @@ class DatasourceProviderService:
|
|||||||
"author": datasource.declaration.identity.author,
|
"author": datasource.declaration.identity.author,
|
||||||
"credentials_list": credentials,
|
"credentials_list": credentials,
|
||||||
"credential_schema": [
|
"credential_schema": [
|
||||||
{
|
credential.model_dump()
|
||||||
"type": credential.type.value,
|
|
||||||
"name": credential.name,
|
|
||||||
"required": credential.required,
|
|
||||||
"default": credential.default,
|
|
||||||
"options": [
|
|
||||||
{
|
|
||||||
"value": option.value,
|
|
||||||
"label": option.label.model_dump(),
|
|
||||||
}
|
|
||||||
for option in credential.options or []
|
|
||||||
],
|
|
||||||
}
|
|
||||||
for credential in datasource.declaration.credentials_schema
|
for credential in datasource.declaration.credentials_schema
|
||||||
],
|
],
|
||||||
"oauth_schema": {
|
"oauth_schema": {
|
||||||
"client_schema": [
|
"client_schema": [
|
||||||
{
|
client_schema.model_dump()
|
||||||
"type": client_schema.type.value,
|
for client_schema in datasource.declaration.oauth_schema.client_schema
|
||||||
"name": client_schema.name,
|
|
||||||
"required": client_schema.required,
|
|
||||||
"default": client_schema.default,
|
|
||||||
"options": [
|
|
||||||
{
|
|
||||||
"value": option.value,
|
|
||||||
"label": option.label.model_dump(),
|
|
||||||
}
|
|
||||||
for option in client_schema.options or []
|
|
||||||
],
|
|
||||||
}
|
|
||||||
for client_schema in datasource.declaration.oauth_schema.client_schema or []
|
|
||||||
],
|
],
|
||||||
"credentials_schema": [
|
"credentials_schema": [
|
||||||
{
|
credential_schema.model_dump()
|
||||||
"type": credential.type.value,
|
for credential_schema in datasource.declaration.oauth_schema.credentials_schema
|
||||||
"name": credential.name,
|
|
||||||
"required": credential.required,
|
|
||||||
"default": credential.default,
|
|
||||||
"options": [
|
|
||||||
{
|
|
||||||
"value": option.value,
|
|
||||||
"label": option.label.model_dump(),
|
|
||||||
}
|
|
||||||
for option in credential.options or []
|
|
||||||
],
|
|
||||||
}
|
|
||||||
for credential in datasource.declaration.oauth_schema.credentials_schema or []
|
|
||||||
],
|
],
|
||||||
"oauth_custom_client_params": self.get_tenant_oauth_client(tenant_id, datasource_provider_id),
|
"oauth_custom_client_params": self.get_tenant_oauth_client(tenant_id, datasource_provider_id),
|
||||||
"is_oauth_custom_client_enabled": self.is_tenant_oauth_params_enabled(
|
"is_oauth_custom_client_enabled": self.is_tenant_oauth_params_enabled(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user