json-schema-to-typescript icon indicating copy to clipboard operation
json-schema-to-typescript copied to clipboard

unreachableDefinitions doesn't work without declareExternallyReferenced

Open patrickbenjamin1 opened this issue 8 months ago • 0 comments

I have many schema files, some of which contain multiple schemas through $defs

i.e.

{
  "$defs": {
    "CreateThingRequestBody": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        }
      }
    },

    "CreateThingResponseBody": {
      "properties": {
        "thing": {
          "$ref": "/schemas/entities/thing.schema.json"
        }
      },
      "additionalProperties": false
    }
  }
}

From the above file, I'd like to be able to generate a type for CreateThingRequestBody and CreateThingResponseBody without redeclaring the type for Thing

My script goes through my schemas file by file, so I want Thing to only be generated when it gets to /schemas/entities/thing.schema.json

unreachableDefinitions should achieve this, but for some reason it only works when declareExternallyReferenced is true

patrickbenjamin1 avatar Feb 17 '25 12:02 patrickbenjamin1