2

I am working on Generating JSON Schema from .NET type using NJsonSchema. I am getting references("$ref"...) for complex type in the generated json.

"properties": {
    "resourceType": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "onset": {
      "type": "string"
    },
    "recorder": { 
      "$ref": "#/definitions/ResourceReference"
    },

I do not want references , instead i want entire block here itself. I have tried below line of code but it does-not seems to be working.

var generator = new NJsonSchema.Generation.JsonSchemaGenerator(new JsonSchemaGeneratorSettings { AllowReferencesWithProperties = false });

I was able to do this by using Newtonsoft.Json package(see below code), but Newtosoft.Json had limitation of 10 schema generation per hour , i had to switch to NJsonSchema.

var generator = new JSchemaGenerator { SchemaReferenceHandling = SchemaReferenceHandling.None };

Is there any way i can have the entire block and not have it referenced using NJsonSchema.

Anish
  • 121
  • 1
  • 8
  • Why not just manually copy the ResourceReference reference into the place where you want it to be? – Ether Jun 17 '20 at 15:12
  • Its more that 3000 line Json file which is being generated from number of .Net classes. – Anish Jun 17 '20 at 16:30
  • did you find the answer? – CageE Mar 30 '21 at 12:28
  • 1
    @CageE NjsonSchema does not support this as of now , the owner has marked this requirement as enhancement. You can track it here https://github.com/RicoSuter/NJsonSchema/issues/642 – Anish Apr 23 '21 at 05:28

0 Answers0