RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.4k stars 535 forks source link

Using NJsonSchema with IEnumerable doesn't escape strings. #1306

Open jbvouma opened 3 years ago

jbvouma commented 3 years ago

Hi,

We have currently an issue with the way an enumerable of strings is generated in the json schema. Basically if we have a parameter

[Parameters.Tags]
public IEnumerable<string> Tags { get; set; }

with default value value = new[] { "og", "fb", "twitter"};

The generated value in the schema looks like:

"Parameters": {
      "Tags": {
        "value": "[og, fb, twitter]"
      }
  }

Shouldn't the value be "[\"og\", \"fb\", \"twitter\"]" with escape strings?

RicoSuter commented 3 years ago

What is [Parameters.Tags]?

jbvouma commented 3 years ago

We have two classes, Parameters that contains all parameters' descriptions and Configuration that we use to generate the JSON schemas.

Parameters contains:

public Tags()
{
    Label = "tags";
    Description = "My tags.";
    DefaultValue = new[] {
        "og:",
        "fb:",
        "twitter:"
    };
    Visibility = VisibilityType.Internal;
}

And Configuration:

[Parameters.Tags]
public IEnumerable<string> Tags { get; set; }