Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如果设置开放api的时候没有应用协议会提示 #1314

Merged
merged 3 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/v1/schema/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, List
from typing import Any, List, Optional
from pydantic import Field
from ninja import ModelSchema, Schema
from arkid.core.translation import gettext_default as _
Expand Down Expand Up @@ -96,12 +96,12 @@ class ConfigOpenApiVersionSchemaOut(Schema):

version: str = Field(title=_('version', '应用版本'), default='')
openapi_uris: str = Field(title=_('openapi uris', '接口文档地址'), default='')
sync_permission_uri: str = Field(title=_('sync permission uri', '主动触发权限更新地址'), readonly=True)
sync_permission_uri: Optional[str] = Field(title=_('sync permission uri', '主动触发权限更新地址'), readonly=True)


class ConfigOpenApiVersionDataSchemaOut(ResponseSchema):

data: ConfigOpenApiVersionSchemaOut
data: Optional[ConfigOpenApiVersionSchemaOut]


AppProtocolConfigIn = AppProtocolExtension.create_composite_config_schema(
Expand Down
4 changes: 4 additions & 0 deletions api/v1/views/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def get_app_openapi_version(request, tenant_id: str, app_id: str):
获取app的openapi地址和版本
'''
app = get_object_or_404(App, id=app_id, is_del=False)
if app.config is None:
return ErrorDict(ErrorCode.NEED_APP_COFIG)
app_config = app.config.config

from arkid.config import get_app_config as ac
Expand Down Expand Up @@ -173,6 +175,8 @@ def set_app_openapi_version(request, tenant_id: str, app_id: str, data:ConfigOpe
设置app的openapi地址和版本
'''
app = get_object_or_404(App, id=app_id, is_del=False)
if app.config is None:
return ErrorDict(ErrorCode.NEED_APP_COFIG)
config = app.config
app_config = config.config
if data.version and data.openapi_uris:
Expand Down
2 changes: 2 additions & 0 deletions arkid/core/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class ErrorCode(Enum):
CAN_NOT_SET_FRONTEND_URL = ('18006', _('can not set frontend url', '链接已设置或禁止设置'))

PLUG_IN_NOT_START = ('18007', _('plug-in not start', '这个插件没有配置'))

NEED_APP_COFIG = ('18008', _('need app config', '需要先配置应用协议'))

class ErrorDict(dict):

Expand Down