Skip to content

Simplify uniqueItems Tag Parsing to Remove Unnecessary Value Requirement #156

@orange-guo

Description

@orange-guo

Current Behavior

Currently, the uniqueItems tag in the schema parsing function requires a value to be present, even though the value itself serves no actual purpose.

This results in redundant code and unnecessary tag declarations.

For example, the current declaration looks like this:

type HPC资源申请 struct {
    A_集群类型 []集群类型 `json:"集群类型" jsonschema:"title=集群类型,uniqueItems=true"`
}

Expected behavior

It should allow a more simplified version of the declaration:

type HPC资源申请 struct {
    A_集群类型 []集群类型 `json:"集群类型" jsonschema:"title=集群类型,uniqueItems"`
}

Solution

Modify the arrayKeywords function to handle the uniqueItems tag as a flag.

Others

To ensure backward compatibility and that the old logic still works properly, it may be necessary to introduce new branches in the code to handle the new functionality.

If needed, I can submit a follow-up MR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions