+ "text": "[](https://github.com/w3c/spec-generator/actions/workflows/lint.yml)\n[](https://github.com/w3c/spec-generator/actions/workflows/test.yml)\n\n# Spec Generator\n\nThis exposes a service to automatically generate specs from various source formats.\n\n## Running the server\n\nStart the server listening on port 8000 by default:\n\n```bash\nnpm start\n```\n\nYou can specify a port like so:\n\n```bash\nPORT=3000 npm start\n```\n\nWhen developing, you can use auto-reload:\n\n```bash\nnpm run watch\n```\n\n`tsx` can be skipped by building then running directly:\n\n```bash\nnpm run build\nnode server.js\n```\n\nThis also supports the `PORT` environment variable as described above.\n\nTo clear out built files, use `git clean`:\n\n- `git clean -ix` will present an interactive confirmation prompt\n- `git clean -fx` will remove the files immediately\n\n## API\n\nSpec Generator has a single endpoint, which is a `GET /`. This endpoint accepts parameters on its\nquery string. If the call is successful the generated content of the specification is returned.\n\n* `type` (required). The type of generator for this content. Currently the only supported value is\n `respec`.\n* `url` (required). The URL of the draft to fetch and generate from.\n* `publishDate`. The date at which the publication of this draft is supposed to occur.\n\n### Errors\n\nIf a required parameter is missing or has a value that is not understood, the generator returns a\n`400` error with a JSON payload the `error` field of which is the human-readable error message.\n\nIf the specific generator encounters a problem a similar error (mostly likely `500`) with the same\nsort of JSON message is returned. Specific generator types can extend this behaviour. The `respec`\ngenerator only returns `500` errors.\n\nThe HTTP response status code is `200` even when there are processing errors and warnings. Processing errors and warnings are signaled with the help of `x-errors-count` and `x-warnings-count` response headers respectively instead.\n\n## Writing generators\n\nGenerators are simple to write and new ones can easily be added. Simply add a new one under\n`generators` and load it into the `genMap` near the top of `server.js`.\n\nGenerators must export a `generate()` method which takes a URL, a set of parameters (from the list\nof optional ones that the API supports), and a callback to invoke upon completion.\n\nIf there is an error, the callback's first argument must be an object with a `status` field being\nan HTTP error code and a `message` field containing the error message. If the generator is\nsuccessful the first argument is `null` and the second is the generated content.\n"
0 commit comments