{
  "openapi": "3.1.1",
  "info": {
    "title": "Schematic Electrical Rules Check (Typed Pins) API",
    "version": "1.0.0",
    "summary": "Check pin types on every net: output conflicts, undriven inputs, unpowered supply pins",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://ohmforgepinerc.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Check pin types on every net: output conflicts, undriven inputs, unpowered supply pins",
        "description": "Run a typed-pin electrical rules check on an Ohmforge schematic: a pin-conflict matrix over input, output, bidirectional, tri-state, passive, power and open-collector pins plus drive rules for inputs, power inputs and open-collector nets.\n\nMethodology:\n- Every component pin gets an electrical type from Ohmforge's catalog: input, output, bidirectional, tri-state, passive, unspecified, power input, power output, open collector or open emitter. Discrete parts are passive; gate, op-amp and comparator outputs are push-pull outputs; supply pins of the real op-amp, comparator and 555 are power inputs; the 555 discharge pin is open collector; voltage sources, batteries, bench supplies and VCVS outputs are power outputs.\n- Pin conflicts: each unordered pair of pins on one resolved net is looked up in a symmetric matrix (error, warning or no finding), for example output–output and output–power output are errors, output–tri-state is a warning.\n- Drive rules: an input needs another pin on its net that can set its level (anything except inputs and power inputs); a power input needs a power output on its net; a net driven only by open-collector or open-emitter pins needs a pull-up or pull-down part. On the ground net these become warnings, because the ground symbol is a simulation reference rather than a supply.\n- Two-terminal voltage sources are judged per source: both terminals on one net is an error (shorted source), two sources on the same pair of nets is a warning (parallel sources); one shared terminal (series stack or common reference) is normal.\n- At most 100 findings are listed, errors first; the counts always include all findings.\n\nPin types describe Ohmforge's built-in simulation symbols, not specific physical parts. The check does not verify voltage levels, logic families, ratings, timing or PCB rules; no findings does not prove a circuit correct or safe.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "ohmforge_pin_erc",
        "x-owner-app": "ohmforge",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OhmforgePinErcInput"
              },
              "examples": {
                "example1": {
                  "summary": "Two inverter outputs on one net",
                  "value": {
                    "project": "{\n  \"format\": \"ohmforge\",\n  \"version\": 1,\n  \"name\": \"Two inverters fighting\",\n  \"parts\": [\n    {\n      \"id\": \"U1\",\n      \"kind\": \"not\",\n      \"x\": 0,\n      \"y\": 0\n    },\n    {\n      \"id\": \"U2\",\n      \"kind\": \"not\",\n      \"x\": 0,\n      \"y\": 6\n    },\n    {\n      \"id\": \"U3\",\n      \"kind\": \"and\",\n      \"x\": 12,\n      \"y\": 1\n    }\n  ],\n  \"wires\": [\n    {\n      \"id\": \"w1\",\n      \"pts\": [\n        [\n          3,\n          0\n        ],\n        [\n          9,\n          0\n        ]\n      ]\n    },\n    {\n      \"id\": \"w2\",\n      \"pts\": [\n        [\n          3,\n          6\n        ],\n        [\n          6,\n          6\n        ],\n        [\n          6,\n          0\n        ]\n      ]\n    }\n  ]\n}"
                  }
                },
                "example2": {
                  "summary": "555 timer without a supply",
                  "value": {
                    "project": "{\n  \"format\": \"ohmforge\",\n  \"version\": 1,\n  \"name\": \"555 without a supply\",\n  \"parts\": [\n    {\n      \"id\": \"U1\",\n      \"kind\": \"timer555\",\n      \"x\": 0,\n      \"y\": 0\n    },\n    {\n      \"id\": \"R1\",\n      \"kind\": \"resistor\",\n      \"x\": -8,\n      \"y\": -2\n    }\n  ],\n  \"wires\": [\n    {\n      \"id\": \"w1\",\n      \"pts\": [\n        [\n          -6,\n          -2\n        ],\n        [\n          -4,\n          -2\n        ]\n      ]\n    }\n  ]\n}"
                  }
                },
                "example3": {
                  "summary": "Battery, resistor and LED (clean)",
                  "value": {
                    "project": "{\n  \"format\": \"ohmforge\",\n  \"version\": 1,\n  \"name\": \"LED on 9 V\",\n  \"parts\": [\n    {\n      \"id\": \"BT1\",\n      \"kind\": \"battery\",\n      \"x\": 0,\n      \"y\": 0,\n      \"props\": {\n        \"footprint\": \"Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical\"\n      }\n    },\n    {\n      \"id\": \"R1\",\n      \"kind\": \"resistor\",\n      \"x\": 4,\n      \"y\": -2,\n      \"props\": {\n        \"value\": \"470\",\n        \"footprint\": \"Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal\"\n      }\n    },\n    {\n      \"id\": \"D1\",\n      \"kind\": \"led\",\n      \"x\": 8,\n      \"y\": 0,\n      \"rot\": 90,\n      \"props\": {\n        \"footprint\": \"LED_THT:LED_D5.0mm\"\n      }\n    },\n    {\n      \"id\": \"GND1\",\n      \"kind\": \"ground\",\n      \"x\": 0,\n      \"y\": 4\n    }\n  ],\n  \"wires\": [\n    {\n      \"id\": \"w1\",\n      \"pts\": [\n        [\n          0,\n          -2\n        ],\n        [\n          2,\n          -2\n        ]\n      ]\n    },\n    {\n      \"id\": \"w2\",\n      \"pts\": [\n        [\n          6,\n          -2\n        ],\n        [\n          8,\n          -2\n        ]\n      ]\n    },\n    {\n      \"id\": \"w3\",\n      \"pts\": [\n        [\n          8,\n          2\n        ],\n        [\n          8,\n          4\n        ],\n        [\n          0,\n          4\n        ]\n      ]\n    },\n    {\n      \"id\": \"w4\",\n      \"pts\": [\n        [\n          0,\n          2\n        ],\n        [\n          0,\n          4\n        ]\n      ]\n    }\n  ]\n}"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OhmforgePinErcResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "OhmforgePinErcInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "project": {
            "title": "Ohmforge project JSON",
            "description": "Paste an exported .ohmforge.json project (at most 200 parts and 200 wires).",
            "type": "string",
            "maxLength": 200000,
            "default": "{\n  \"format\": \"ohmforge\",\n  \"version\": 1,\n  \"name\": \"Two inverters fighting\",\n  \"parts\": [\n    {\n      \"id\": \"U1\",\n      \"kind\": \"not\",\n      \"x\": 0,\n      \"y\": 0\n    },\n    {\n      \"id\": \"U2\",\n      \"kind\": \"not\",\n      \"x\": 0,\n      \"y\": 6\n    },\n    {\n      \"id\": \"U3\",\n      \"kind\": \"and\",\n      \"x\": 12,\n      \"y\": 1\n    }\n  ],\n  \"wires\": [\n    {\n      \"id\": \"w1\",\n      \"pts\": [\n        [\n          3,\n          0\n        ],\n        [\n          9,\n          0\n        ]\n      ]\n    },\n    {\n      \"id\": \"w2\",\n      \"pts\": [\n        [\n          3,\n          6\n        ],\n        [\n          6,\n          6\n        ],\n        [\n          6,\n          0\n        ]\n      ]\n    }\n  ]\n}"
          }
        },
        "required": []
      },
      "OhmforgePinErcResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "projectName",
              "version",
              "pins",
              "pinsByType",
              "errors",
              "warnings",
              "totalFindings",
              "omittedFindings",
              "pairCheckSkippedNets",
              "findings"
            ],
            "properties": {
              "projectName": {
                "type": "string"
              },
              "version": {
                "type": "integer"
              },
              "pins": {
                "type": "integer",
                "minimum": 0
              },
              "pinsByType": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "input",
                  "output",
                  "bidirectional",
                  "tri_state",
                  "passive",
                  "unspecified",
                  "power_in",
                  "power_out",
                  "open_collector",
                  "open_emitter"
                ],
                "properties": {
                  "input": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "output": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "bidirectional": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "tri_state": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "passive": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "unspecified": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "power_in": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "power_out": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "open_collector": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "open_emitter": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              },
              "errors": {
                "type": "integer",
                "minimum": 0
              },
              "warnings": {
                "type": "integer",
                "minimum": 0
              },
              "totalFindings": {
                "type": "integer",
                "minimum": 0
              },
              "omittedFindings": {
                "type": "integer",
                "minimum": 0
              },
              "pairCheckSkippedNets": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "findings": {
                "type": "array",
                "maxItems": 100,
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "rule",
                    "severity",
                    "net",
                    "ground",
                    "terminals",
                    "message"
                  ],
                  "properties": {
                    "rule": {
                      "type": "string",
                      "enum": [
                        "pin-conflict",
                        "input-not-driven",
                        "power-input-not-driven",
                        "open-drain-without-pull",
                        "shorted-source",
                        "parallel-sources"
                      ]
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "warning",
                        "error"
                      ]
                    },
                    "net": {
                      "type": "string"
                    },
                    "ground": {
                      "type": "boolean"
                    },
                    "terminals": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "partId",
                          "pin",
                          "type",
                          "point"
                        ],
                        "properties": {
                          "partId": {
                            "type": "string"
                          },
                          "pin": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "input",
                              "output",
                              "bidirectional",
                              "tri_state",
                              "passive",
                              "unspecified",
                              "power_in",
                              "power_out",
                              "open_collector",
                              "open_emitter"
                            ]
                          },
                          "point": {
                            "type": "array",
                            "items": {
                              "type": "integer"
                            },
                            "minItems": 2,
                            "maxItems": 2
                          }
                        }
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}