StefanTerdell / json-schema-to-zod

ISC License
332 stars 48 forks source link

Error ENAMETOOLONG when piping with json-refs #74

Closed pSnehanshu closed 11 months ago

pSnehanshu commented 11 months ago

Schema file: BootNotificationRequest.json

Command:

json-refs resolve BootNotificationRequest.json | json-schema-to-zod | prettier --parser typescript > BootNotificationRequest.ts

Error:

node:fs:1596
  handleErrorFromBinding(ctx);
  ^

Error: ENAMETOOLONG: name too long, stat '{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "$id": "urn:OCPP:Cp:2:2020:3:BootNotificationRequest",
  "comment": "OCPP 2.0.1 FINAL",
  "definitions": {
    "CustomDataType": {
      "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",
      "javaType": "CustomData",
      "type": "object",
      "properties": {
        "vendorId": {
          "type": "string",
          "maxLength": 255
        }
      },
      "required": [
        "vendorId"
      ]
    },
    "BootReasonEnumType": {
      "description": "This contains the reason for sending this message to the CSMS.\r\n",
      "javaType": "BootReasonEnum",
      "type": "string",
      "additionalProperties": false,
      "enum": [
        "ApplicationReset",
        "FirmwareUpdate",
        "LocalReset",
        "PowerUp",
        "RemoteReset",
        "ScheduledReset",
        "Triggered",
        "Unknown",
        "Watchdog"
      ]
    },
    "ChargingStationType": {
      "description": "Charge_ Point\r\nurn:x-oca:ocpp:uid:2:233122\r\nThe physical system where an Electrical Vehicle (EV) can be charged.\r\n",
      "javaType": "ChargingStation",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "customData": {
          "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",
          "javaType": "CustomData",
          "type": "object",
          "properties": {
            "vendorId": {
              "type": "string",
              "maxLength": 255
            }
          },
          "required": [
            "vendorId"
          ]
        },
        "serialNumber": {
          "description": "Device. Serial_ Number. Serial_ Number\r\nurn:x-oca:ocpp:uid:1:569324\r\nVendor-specific device identifier.\r\n",
          "type": "string",
          "maxLength": 25
        },
        "model": {
          "description": "Device. Model. CI20_ Text\r\nurn:x-oca:ocpp:uid:1:569325\r\nDefines the model of the device.\r\n",
          "type": "string",
          "maxLength": 20
        },
        "modem": {
          "description": "Wireless_ Communication_ Module\r\nurn:x-oca:ocpp:uid:2:233306\r\nDefines parameters required for initiating and maintaining wireless communication with other devices.\r\n",
          "javaType": "Modem",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "customData": {
              "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",
              "javaType": "CustomData",
              "type": "object",
              "properties": {
                "vendorId": {
                  "type": "string",
                  "maxLength": 255
                }
              },
              "required": [
                "vendorId"
              ]
            },
            "iccid": {
              "description": "Wireless_ Communication_ Module. ICCID. CI20_ Text\r\nurn:x-oca:ocpp:uid:1:569327\r\nThis contains the ICCID of the modem’s SIM card.\r\n",
              "type": "string",
              "maxLength": 20
            },
            "imsi": {
              "description": "Wireless_ Communication_ Module. IMSI. CI20_ Text\r\nurn:x-oca:ocpp:uid:1:569328\r\nThis contains the IMSI of the modem’s SIM card.\r\n",
              "type": "string",
              "maxLength": 20
            }
          }
        },
        "vendorName": {
          "description": "Identifies the vendor (not necessarily in a unique manner).\r\n",
          "type": "string",
          "maxLength": 50
        },
        "firmwareVersion": {
          "description": "This contains the firmware version of the Charging Station.\r\n\r\n",
          "type": "string",
          "maxLength": 50
        }
      },
      "required": [
        "model",
        "vendorName"
      ]
    },
    "ModemType": {
      "description": "Wireless_ Communication_ Module\r\nurn:x-oca:ocpp:uid:2:233306\r\nDefines parameters required for initiating and maintaining wireless communication with other devices.\r\n",
      "javaType": "Modem",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "customData": {
          "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",
          "javaType": "CustomData",
          "type": "object",
          "properties": {
            "vendorId": {
              "type": "string",
              "maxLength": 255
            }
          },
          "required": [
            "vendorId"
          ]
        },
        "iccid": {
          "description": "Wireless_ Communication_ Module. ICCID. CI20_ Text\r\nurn:x-oca:ocpp:uid:1:569327\r\nThis contains the ICCID of the modem’s SIM card.\r\n",
          "type": "string",
          "maxLength": 20
        },
        "imsi": {
          "description": "Wireless_ Communication_ Module. IMSI. CI20_ Text\r\nurn:x-oca:ocpp:uid:1:569328\r\nThis contains the IMSI of the modem’s SIM card.\r\n",
          "type": "string",
          "maxLength": 20
        }
      }
    }
  },
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "customData": {
      "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",
      "javaType": "CustomData",
      "type": "object",
      "properties": {
        "vendorId": {
          "type": "string",
          "maxLength": 255
        }
      },
      "required": [
        "vendorId"
      ]
    },
    "chargingStation": {
      "description": "Charge_ Point\r\nurn:x-oca:ocpp:uid:2:233122\r\nThe physical system where an Electrical Vehicle (EV) can be charged.\r\n",
      "javaType": "ChargingStation",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "customData": {
          "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",
          "javaType": "CustomData",
          "type": "object",
          "properties": {
            "vendorId": {
              "type": "string",
              "maxLength": 255
            }
          },
          "required": [
            "vendorId"
          ]
        },
        "serialNumber": {
          "description": "Device. Serial_ Number. Serial_ Number\r\nurn:x-oca:ocpp:uid:1:569324\r\nVendor-specific device identifier.\r\n",
          "type": "string",
          "maxLength": 25
        },
        "model": {
          "description": "Device. Model. CI20_ Text\r\nurn:x-oca:ocpp:uid:1:569325\r\nDefines the model of the device.\r\n",
          "type": "string",
          "maxLength": 20
        },
        "modem": {
          "description": "Wireless_ Communication_ Module\r\nurn:x-oca:ocpp:uid:2:233306\r\nDefines parameters required for initiating and maintaining wireless communication with other devices.\r\n",
          "javaType": "Modem",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "customData": {
              "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",
              "javaType": "CustomData",
              "type": "object",
              "properties": {
                "vendorId": {
                  "type": "string",
                  "maxLength": 255
                }
              },
              "required": [
                "vendorId"
              ]
            },
            "iccid": {
              "description": "Wireless_ Communication_ Module. ICCID. CI20_ Text\r\nurn:x-oca:ocpp:uid:1:569327\r\nThis contains the ICCID of the modem’s SIM card.\r\n",
              "type": "string",
              "maxLength": 20
            },
            "imsi": {
              "description": "Wireless_ Communication_ Module. IMSI. CI20_ Text\r\nurn:x-oca:ocpp:uid:1:569328\r\nThis contains the IMSI of the modem’s SIM card.\r\n",
              "type": "string",
              "maxLength": 20
            }
          }
        },
        "vendorName": {
          "description": "Identifies the vendor (not necessarily in a unique manner).\r\n",
          "type": "string",
          "maxLength": 50
        },
        "firmwareVersion": {
          "description": "This contains the firmware version of the Charging Station.\r\n\r\n",
          "type": "string",
          "maxLength": 50
        }
      },
      "required": [
        "model",
        "vendorName"
      ]
    },
    "reason": {
      "description": "This contains the reason for sending this message to the CSMS.\r\n",
      "javaType": "BootReasonEnum",
      "type": "string",
      "additionalProperties": false,
      "enum": [
        "ApplicationReset",
        "FirmwareUpdate",
        "LocalReset",
        "PowerUp",
        "RemoteReset",
        "ScheduledReset",
        "Triggered",
        "Unknown",
        "Watchdog"
      ]
    }
  },
  "required": [
    "reason",
    "chargingStation"
  ]
}'
    at statSync (node:fs:1596:3)
    at parseOrReadJSON (/home/snehanshu/.nvm/versions/node/v18.13.0/lib/node_modules/json-schema-to-zod/dist/cjs/utils/cliTools.js:65:27)
    at main (/home/snehanshu/.nvm/versions/node/v18.13.0/lib/node_modules/json-schema-to-zod/dist/cjs/cli.js:40:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errno: -36,
  syscall: 'stat',
  code: 'ENAMETOOLONG',
  path: '{\n' +
    '  "$schema": "http://json-schema.org/draft-06/schema#",\n' +
    '  "$id": "urn:OCPP:Cp:2:2020:3:BootNotificationRequest",\n' +
    '  "comment": "OCPP 2.0.1 FINAL",\n' +
    '  "definitions": {\n' +
    '    "CustomDataType": {\n' +
    `      "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",\n` +
    '      "javaType": "CustomData",\n' +
    '      "type": "object",\n' +
    '      "properties": {\n' +
    '        "vendorId": {\n' +
    '          "type": "string",\n' +
    '          "maxLength": 255\n' +
    '        }\n' +
    '      },\n' +
    '      "required": [\n' +
    '        "vendorId"\n' +
    '      ]\n' +
    '    },\n' +
    '    "BootReasonEnumType": {\n' +
    '      "description": "This contains the reason for sending this message to the CSMS.\\r\\n",\n' +
    '      "javaType": "BootReasonEnum",\n' +
    '      "type": "string",\n' +
    '      "additionalProperties": false,\n' +
    '      "enum": [\n' +
    '        "ApplicationReset",\n' +
    '        "FirmwareUpdate",\n' +
    '        "LocalReset",\n' +
    '        "PowerUp",\n' +
    '        "RemoteReset",\n' +
    '        "ScheduledReset",\n' +
    '        "Triggered",\n' +
    '        "Unknown",\n' +
    '        "Watchdog"\n' +
    '      ]\n' +
    '    },\n' +
    '    "ChargingStationType": {\n' +
    '      "description": "Charge_ Point\\r\\nurn:x-oca:ocpp:uid:2:233122\\r\\nThe physical system where an Electrical Vehicle (EV) can be charged.\\r\\n",\n' +
    '      "javaType": "ChargingStation",\n' +
    '      "type": "object",\n' +
    '      "additionalProperties": false,\n' +
    '      "properties": {\n' +
    '        "customData": {\n' +
    `          "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",\n` +
    '          "javaType": "CustomData",\n' +
    '          "type": "object",\n' +
    '          "properties": {\n' +
    '            "vendorId": {\n' +
    '              "type": "string",\n' +
    '              "maxLength": 255\n' +
    '            }\n' +
    '          },\n' +
    '          "required": [\n' +
    '            "vendorId"\n' +
    '          ]\n' +
    '        },\n' +
    '        "serialNumber": {\n' +
    '          "description": "Device. Serial_ Number. Serial_ Number\\r\\nurn:x-oca:ocpp:uid:1:569324\\r\\nVendor-specific device identifier.\\r\\n",\n' +
    '          "type": "string",\n' +
    '          "maxLength": 25\n' +
    '        },\n' +
    '        "model": {\n' +
    '          "description": "Device. Model. CI20_ Text\\r\\nurn:x-oca:ocpp:uid:1:569325\\r\\nDefines the model of the device.\\r\\n",\n' +
    '          "type": "string",\n' +
    '          "maxLength": 20\n' +
    '        },\n' +
    '        "modem": {\n' +
    '          "description": "Wireless_ Communication_ Module\\r\\nurn:x-oca:ocpp:uid:2:233306\\r\\nDefines parameters required for initiating and maintaining wireless communication with other devices.\\r\\n",\n' +
    '          "javaType": "Modem",\n' +
    '          "type": "object",\n' +
    '          "additionalProperties": false,\n' +
    '          "properties": {\n' +
    '            "customData": {\n' +
    `              "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",\n` +
    '              "javaType": "CustomData",\n' +
    '              "type": "object",\n' +
    '              "properties": {\n' +
    '                "vendorId": {\n' +
    '                  "type": "string",\n' +
    '                  "maxLength": 255\n' +
    '                }\n' +
    '              },\n' +
    '              "required": [\n' +
    '                "vendorId"\n' +
    '              ]\n' +
    '            },\n' +
    '            "iccid": {\n' +
    '              "description": "Wireless_ Communication_ Module. ICCID. CI20_ Text\\r\\nurn:x-oca:ocpp:uid:1:569327\\r\\nThis contains the ICCID of the modem’s SIM card.\\r\\n",\n' +
    '              "type": "string",\n' +
    '              "maxLength": 20\n' +
    '            },\n' +
    '            "imsi": {\n' +
    '              "description": "Wireless_ Communication_ Module. IMSI. CI20_ Text\\r\\nurn:x-oca:ocpp:uid:1:569328\\r\\nThis contains the IMSI of the modem’s SIM card.\\r\\n",\n' +
    '              "type": "string",\n' +
    '              "maxLength": 20\n' +
    '            }\n' +
    '          }\n' +
    '        },\n' +
    '        "vendorName": {\n' +
    '          "description": "Identifies the vendor (not necessarily in a unique manner).\\r\\n",\n' +
    '          "type": "string",\n' +
    '          "maxLength": 50\n' +
    '        },\n' +
    '        "firmwareVersion": {\n' +
    '          "description": "This contains the firmware version of the Charging Station.\\r\\n\\r\\n",\n' +
    '          "type": "string",\n' +
    '          "maxLength": 50\n' +
    '        }\n' +
    '      },\n' +
    '      "required": [\n' +
    '        "model",\n' +
    '        "vendorName"\n' +
    '      ]\n' +
    '    },\n' +
    '    "ModemType": {\n' +
    '      "description": "Wireless_ Communication_ Module\\r\\nurn:x-oca:ocpp:uid:2:233306\\r\\nDefines parameters required for initiating and maintaining wireless communication with other devices.\\r\\n",\n' +
    '      "javaType": "Modem",\n' +
    '      "type": "object",\n' +
    '      "additionalProperties": false,\n' +
    '      "properties": {\n' +
    '        "customData": {\n' +
    `          "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",\n` +
    '          "javaType": "CustomData",\n' +
    '          "type": "object",\n' +
    '          "properties": {\n' +
    '            "vendorId": {\n' +
    '              "type": "string",\n' +
    '              "maxLength": 255\n' +
    '            }\n' +
    '          },\n' +
    '          "required": [\n' +
    '            "vendorId"\n' +
    '          ]\n' +
    '        },\n' +
    '        "iccid": {\n' +
    '          "description": "Wireless_ Communication_ Module. ICCID. CI20_ Text\\r\\nurn:x-oca:ocpp:uid:1:569327\\r\\nThis contains the ICCID of the modem’s SIM card.\\r\\n",\n' +
    '          "type": "string",\n' +
    '          "maxLength": 20\n' +
    '        },\n' +
    '        "imsi": {\n' +
    '          "description": "Wireless_ Communication_ Module. IMSI. CI20_ Text\\r\\nurn:x-oca:ocpp:uid:1:569328\\r\\nThis contains the IMSI of the modem’s SIM card.\\r\\n",\n' +
    '          "type": "string",\n' +
    '          "maxLength": 20\n' +
    '        }\n' +
    '      }\n' +
    '    }\n' +
    '  },\n' +
    '  "type": "object",\n' +
    '  "additionalProperties": false,\n' +
    '  "properties": {\n' +
    '    "customData": {\n' +
    `      "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",\n` +
    '      "javaType": "CustomData",\n' +
    '      "type": "object",\n' +
    '      "properties": {\n' +
    '        "vendorId": {\n' +
    '          "type": "string",\n' +
    '          "maxLength": 255\n' +
    '        }\n' +
    '      },\n' +
    '      "required": [\n' +
    '        "vendorId"\n' +
    '      ]\n' +
    '    },\n' +
    '    "chargingStation": {\n' +
    '      "description": "Charge_ Point\\r\\nurn:x-oca:ocpp:uid:2:233122\\r\\nThe physical system where an Electrical Vehicle (EV) can be charged.\\r\\n",\n' +
    '      "javaType": "ChargingStation",\n' +
    '      "type": "object",\n' +
    '      "additionalProperties": false,\n' +
    '      "properties": {\n' +
    '        "customData": {\n' +
    `          "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",\n` +
    '          "javaType": "CustomData",\n' +
    '          "type": "object",\n' +
    '          "properties": {\n' +
    '            "vendorId": {\n' +
    '              "type": "string",\n' +
    '              "maxLength": 255\n' +
    '            }\n' +
    '          },\n' +
    '          "required": [\n' +
    '            "vendorId"\n' +
    '          ]\n' +
    '        },\n' +
    '        "serialNumber": {\n' +
    '          "description": "Device. Serial_ Number. Serial_ Number\\r\\nurn:x-oca:ocpp:uid:1:569324\\r\\nVendor-specific device identifier.\\r\\n",\n' +
    '          "type": "string",\n' +
    '          "maxLength": 25\n' +
    '        },\n' +
    '        "model": {\n' +
    '          "description": "Device. Model. CI20_ Text\\r\\nurn:x-oca:ocpp:uid:1:569325\\r\\nDefines the model of the device.\\r\\n",\n' +
    '          "type": "string",\n' +
    '          "maxLength": 20\n' +
    '        },\n' +
    '        "modem": {\n' +
    '          "description": "Wireless_ Communication_ Module\\r\\nurn:x-oca:ocpp:uid:2:233306\\r\\nDefines parameters required for initiating and maintaining wireless communication with other devices.\\r\\n",\n' +
    '          "javaType": "Modem",\n' +
    '          "type": "object",\n' +
    '          "additionalProperties": false,\n' +
    '          "properties": {\n' +
    '            "customData": {\n' +
    `              "description": "This class does not get 'AdditionalProperties = false' in the schema generation, so it can be extended with arbitrary JSON properties to allow adding custom data.",\n` +
    '              "javaType": "CustomData",\n' +
    '              "type": "object",\n' +
    '              "properties": {\n' +
    '                "vendorId": {\n' +
    '                  "type": "string",\n' +
    '                  "maxLength": 255\n' +
    '                }\n' +
    '              },\n' +
    '              "required": [\n' +
    '                "vendorId"\n' +
    '              ]\n' +
    '            },\n' +
    '            "iccid": {\n' +
    '              "description": "Wireless_ Communication_ Module. ICCID. CI20_ Text\\r\\nurn:x-oca:ocpp:uid:1:569327\\r\\nThis contains the ICCID of the modem’s SIM card.\\r\\n",\n' +
    '              "type": "string",\n' +
    '              "maxLength": 20\n' +
    '            },\n' +
    '            "imsi": {\n' +
    '              "description": "Wireless_ Communication_ Module. IMSI. CI20_ Text\\r\\nurn:x-oca:ocpp:uid:1:569328\\r\\nThis contains the IMSI of the modem’s SIM card.\\r\\n",\n' +
    '              "type": "string",\n' +
    '              "maxLength": 20\n' +
    '            }\n' +
    '          }\n' +
    '        },\n' +
    '        "vendorName": {\n' +
    '          "description": "Identifies the vendor (not necessarily in a unique manner).\\r\\n",\n' +
    '          "type": "string",\n' +
    '          "maxLength": 50\n' +
    '        },\n' +
    '        "firmwareVersion": {\n' +
    '          "description": "This contains the firmware version of the Charging Station.\\r\\n\\r\\n",\n' +
    '          "type": "string",\n' +
    '          "maxLength": 50\n' +
    '        }\n' +
    '      },\n' +
    '      "required": [\n' +
    '        "model",\n' +
    '        "vendorName"\n' +
    '      ]\n' +
    '    },\n' +
    '    "reason": {\n' +
    '      "description": "This contains the reason for sending this message to the CSMS.\\r\\n",\n' +
    '      "javaType": "BootReasonEnum",\n' +
    '      "type": "string",\n' +
    '      "additionalProperties": false,\n' +
    '      "enum": [\n' +
    '        "ApplicationReset",\n' +
    '        "FirmwareUpdate",\n' +
    '        "LocalReset",\n' +
    '        "PowerUp",\n' +
    '        "RemoteReset",\n' +
    '        "ScheduledReset",\n' +
    '        "Triggered",\n' +
    '        "Unknown",\n' +
    '        "Watchdog"\n' +
    '      ]\n' +
    '    }\n' +
    '  },\n' +
    '  "required": [\n' +
    '    "reason",\n' +
    '    "chargingStation"\n' +
    '  ]\n' +
    '}'
}

Node.js v18.13.0
StefanTerdell commented 11 months ago

Works on my machine TM

Tested on win 10, with node@18.17.1 and node@20.0.9, and json-refs@3.0.15, prettier@3.1.0 and json-schema-to-zod @2.0.10

I can check on Mac tomorrow

StefanTerdell commented 11 months ago

Huh yeah, could replicate on Mac. Score 1 for Windows. Unix-guys in literal shambles.

Fixed in 2.0.11

pSnehanshu commented 11 months ago

Right, I forgot to mention that I was using Windows with WSL, so technically still Unix. Thanks for the fix.

However I don't see any new commits on GitHub but I see a new published version on NPM. Did you npm publish without git push?

StefanTerdell commented 11 months ago

maybe

maybe not

maybe mind your own business

/jk