NJsonSchema icon indicating copy to clipboard operation
NJsonSchema copied to clipboard

Sample generation fails to generate values when re-using definitions in schema

Open leflings opened this issue 2 years ago • 0 comments

Given this schema:

{
    "definitions": {
        "withNumber": {
            "type": "object",
            "required": ["value"],
            "properties": {
                "value": {
                    "type": "number"
                }
            }
        }
    },
    "type": "object",
    "required": ["number1", "number2"],
    "properties": {
        "number1": { "$ref": "#/definitions/withNumber" },
        "number2": { "$ref": "#/definitions/withNumber" }
    }
}

I get the following JSON when using SampleJsonDataGenerator:

{
  "number1": {
    "value": 0.0
  },
  "number2": null
}

Where I would expect it to generate the following:

{
  "number1": {
    "value": 0.0
  },
  "number2": {
    "value": 0.0
  }
}

leflings avatar Oct 02 '22 07:10 leflings