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

When the schema has required fields, unexpanded {} will not trigger validation, expanded {} can trigger validation #105

Open
rookie-luochao opened this issue May 31, 2024 · 8 comments

Comments

@rookie-luochao
Copy link

image image

my use schema:

{
    "type": "object",
    "properties": {
        "opsProjectID": {
            "type": "string",
            "description": "项目id",
            "x-go-field-name": "OpsProjectID",
            "x-tag-json": "opsProjectID"
        },
        "packageVersionID": {
            "type": "string",
            "description": "部署包版本id",
            "x-go-field-name": "PackageVersionID",
            "x-tag-json": "packageVersionID"
        },
        "remark": {
            "type": "string",
            "description": "发布描述",
            "x-go-field-name": "Remark",
            "x-tag-json": "remark"
        },
        "envs": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "agentID": {
                        "type": "string",
                        "description": "集群",
                        "x-go-field-name": "AgentID",
                        "x-tag-json": "agentID"
                    },
                    "copyAgentIDs": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "需要copy的集群集合\n\nApplicationTemplateInstanceSet []*ApplicationRelateTemplateAndInstance `json:\"applicationTemplateInstance,omitempty\"` // 服务模版实例关联",
                        "x-go-field-name": "CopyAgentIDs",
                        "x-tag-json": "copyAgentIDs,omitempty"
                    },
                    "namespace": {
                        "type": "string",
                        "description": "命名空间",
                        "x-go-field-name": "Namespace",
                        "x-tag-json": "namespace"
                    }
                },
                "required": [
                    "agentID",
                    "namespace"
                ],
                "x-id": "ApplyEnvRequest"
            },
            "description": "环境集合",
            "x-go-field-name": "Envs",
            "x-tag-json": "envs"
        }
    },
    "required": [
        "opsProjectID",
        "packageVersionID",
        "remark",
        "envs"
    ],
    "x-id": "CreateApplyParams",
    "x-go-field-name": "Body"
}

associate #99, this bug has not been resolved, unable to reopen bug

when the schema has required fields, expect that both unexpanded or expanded {} can trigger verification

@rookie-luochao
Copy link
Author

@imolorhe please confirm this bug, thank you

@imolorhe
Copy link
Collaborator

Yes I can confirm it is still there. Looks like this isn't a bug but is intended? 🤔 cc @acao why do we not want to validate when the doc length is short?
https://github.com/acao/codemirror-json-schema/blob/imolorhe/improve-completion/src/json-validation.ts#L131

imo an empty editor is also invalid but that should also be length of 0 after trimming 🤔

@rookie-luochao
Copy link
Author

I think validation should be done when the document length is short, because it is easy for users to misunderstand that there is no difference between expanding and not expanding null map

@rookie-luochao
Copy link
Author

monaco-editor will also prompt and verify when the map is not expanded,you can try it on monaco-editor. @imolorhe @acao

@acao
Copy link
Collaborator

acao commented May 31, 2024

agreed on all of this, short documents should be validated, i think we should only check to avoid validating for an an empty string.

acao added a commit that referenced this issue Jun 1, 2024
acao added a commit that referenced this issue Jun 1, 2024
@acao acao closed this as completed in edafa8f Jun 1, 2024
@rookie-luochao
Copy link
Author

Maybe you need to verify it with the test schema data I gave you. It seems that this bug has not been solved. When you enter {}, the verification still cannot be triggered @acao @imolorhe

@acao
Copy link
Collaborator

acao commented Jun 2, 2024

@rookie-luochao the issue i fixed was with the text document validation length, did that not solve your issue?

@acao acao reopened this Jun 2, 2024
@rookie-luochao
Copy link
Author

rookie-luochao commented Jun 2, 2024

@rookie-luochao the issue i fixed was with the text document validation length, did that not solve your issue?

I saw your modification, but using the schema I provided, the same problem still occurs. {} still cannot trigger validation, but { } can trigger validation, and line breaks {} can also trigger validation

Seems to have removed < 3 Fixes some issues, But not completely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants