Skip to content

[BUG]FastJson2, JsonSchema, type为数组问题 #2931

@leicen

Description

@leicen

问题描述

简要描述您碰到的问题。

FastJson2, JsonSchema, type为数组问题时,JsonSchema对象被处理为 x: {}

示例:
public static void main(String[] args) throws IOException {

    // 定义必须包含longitude和latitude两个属性,其中longitude的取值范围是[-180 ~ 180],latitude的取值范围是[-90, 90]
    JSONSchema schema = JSONSchema.of(JSON.parseObject("{\"type\":\"object\",\"properties\":{\"longitude\":{\"type\":[\"string\", \"number\"]},\"latitude\":{\"type\":\"number\",\"minimum\":-90,\"maximum\":-90}},\"required\":[\"longitude\",\"latitude\"]}"));

    // 校验JSONObject对象,校验通过
    System.out.println(schema);
}

结果:

{"type":"object","properties":{"longitude":{},"latitude":{"type":"number","minimum":-90,"maximum":-90}},"required":["longitude","latitude"]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions