{"id":29079332,"url":"https://github.com/griffiths-waite/xsd-to-openapi","last_synced_at":"2025-06-27T17:07:59.643Z","repository":{"id":293993499,"uuid":"982894152","full_name":"griffiths-waite/xsd-to-openapi","owner":"griffiths-waite","description":"A tool that converts XSD schemas to modern OpenAPI 3.0 specifications","archived":false,"fork":false,"pushed_at":"2025-05-20T07:55:20.000Z","size":115,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-23T15:55:29.318Z","etag":null,"topics":["json-schema","openapi","openapi-generator","openapi3","xsd","xsd-files","xsd-schema"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/griffiths-waite.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-13T15:01:57.000Z","updated_at":"2025-05-20T07:54:53.000Z","dependencies_parsed_at":"2025-05-18T12:37:00.754Z","dependency_job_id":null,"html_url":"https://github.com/griffiths-waite/xsd-to-openapi","commit_stats":null,"previous_names":["griffiths-waite/xsd-to-openapi"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/griffiths-waite/xsd-to-openapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/griffiths-waite%2Fxsd-to-openapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/griffiths-waite%2Fxsd-to-openapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/griffiths-waite%2Fxsd-to-openapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/griffiths-waite%2Fxsd-to-openapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/griffiths-waite","download_url":"https://codeload.github.com/griffiths-waite/xsd-to-openapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/griffiths-waite%2Fxsd-to-openapi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262298771,"owners_count":23289603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-schema","openapi","openapi-generator","openapi3","xsd","xsd-files","xsd-schema"],"created_at":"2025-06-27T17:02:33.749Z","updated_at":"2025-06-27T17:07:59.620Z","avatar_url":"https://github.com/griffiths-waite.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xsd-to-openapi\nA tool for converting XSD files to OpenAPI 3.1 JSON specifications.\n\n## Installation\n```bash\nnpm install xsd-to-openapi\n```\n\n## Usage\nTo use this tool, you may either specify an `inputFilePath` (the path to your XSD file) or provide the XSD content directly using the `xsdContent` property. The function returns a Promise that resolves to the generated OpenAPI specification object. For more details on available options, see the [Configuration section](#configuration).\n\n**Generation from the file path of an XSD file**\n```ts\nimport { xsdToOpenApi } from \"xsd-to-openapi\";\nimport path from \"path\";\n\nconst myXsdFilePath = path.join(__dirname, \"xsdFiles/mySoapApi.xsd\");\nconst myOutputFilePath = path.join(__dirname, \"mySoapApi-openapi.json\");\n\nawait xsdToOpenApi({\n    inputFilePath: myXsdFilePath,\n    outputFilePath: myOutputFilePath,\n});\n```\n**Generation from an XSD as a string**\n```ts\nconst myXsdString = `\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cxsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\u003e\n    \u003cxsd:element name=\"MyXsdReq\" type=\"MyXsdReq\" /\u003e\n    \u003cxsd:complexType name=\"MyXsdReq\"\u003e\n        \u003cxsd:sequence\u003e\n            \u003cxsd:element name=\"stringField\" type=\"xsd:string\" /\u003e\n            \u003cxsd:element name=\"numberField\" type=\"xsd:decimal\" /\u003e\n        \u003c/xsd:sequence\u003e\n    \u003c/xsd:complexType\u003e\n\n    \u003cxsd:element name=\"MyXsdRes\" type=\"MyXsdRes\" /\u003e\n    \u003cxsd:complexType name=\"MyXsdRes\"\u003e\n        \u003cxsd:sequence\u003e\n            \u003cxsd:element name=\"stringField\" type=\"xsd:string\" /\u003e\n            \u003cxsd:element name=\"numberField\" type=\"xsd:decimal\" /\u003e\n        \u003c/xsd:sequence\u003e\n    \u003c/xsd:complexType\u003e\n\u003c/xsd:schema\u003e\n`\nawait xsdToOpenApi({\n    xsdContent: myXsdString,\n    outputFilePath: myOutputFilePath,\n});\n```\n\nIf you want to write the JSON specification to a file, then you should also specify an `outputFilePath`. However, the generated specification can be consumed programmatically.\n\n## Features\n### XSD Support\n- XSD parsing:\n  - Supports elements, sequences, choices and complex types.\n  - Handles nested elements and types.\n  - Resolves references for elements and types (both internally and from imported XSD schemas).\n- XSD schema imports:\n  - Resolves imports from relative paths (requires `inputFilePath`).\n  - Handle circular references between schemas.\n\n### OpenAPI Spec Generation\n- Generate OpenAPI 3.0/3.1 JSON specifications:\n  - Automatically create paths from matching request/response elements.\n  - Uses naming patterns to generate paths (e.g. `GetUserRequest` and `GetUserResponse` become `/GetUser`).\n  - Configurable suffixes for identifying request/response elements for each endpoint.\n  - Maps common XSD data types to basic JSON data types.\n\n### Configuration\nThe tool can be configured with the following options:\n\n| Option                                         | Type      | Description                                                                                                                                                                                         | Required |\n| ---------------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |\n| `inputFilePath`                                | `String`  | Path to the input XSD file.                                                                                                                                                                         | No       |\n| `outputFilePath`                               | `String`  | Path where the OpenAPI JSON specification file will be written.                                                                                                                                     | No       |\n| `xsdContent`                                   | `String`  | XSD content as a string (used if `inputFilePath` is not provided).                                                                                                                                  | No       |\n| `schemaName`                                   | `String`  | Optional name for the API schema (used as the path name if `useSchemaNameInPath` is `true`).                                                                                                        | No       |\n| `specGenerationOptions`                        | `Object`  | Additional options for customising the process of generating the OpenAPI spec.                                                                                                                      | No       |\n| `specGenerationOptions.requestSuffix`          | `String`  | Suffix for identifying request elements by name (default: `\"Req\"`).                                                                                                                                 | No       |\n| `specGenerationOptions.responseSuffix`         | `String`  | Suffix for identifying response elements by name (default: `\"Res\"`).                                                                                                                                | No       |\n| `specGenerationOptions.useSchemaNameInPath`    | `Boolean` | Whether to include the schema name in the endpoint path (e.g. `schemaName/endpointName`) (default: `false`). If this is set to `true` and `schemaName` is not set, then the file name will be used. | No       |\n| `specGenerationOptions.httpMethod`             | `String`  | HTTP method for all operations (default: `\"post\"`).                                                                                                                                                 | No       |\n| `specGenerationOptions.contentType`            | `String`  | Content type for all operations (default: `\"application/json\"`).                                                                                                                                    | No       |\n| `specGenerationOptions.error`                  | `Object`  | Optional error schema options (applied to all operations and is not included by default).                                                                                                           | No       |\n| `specGenerationOptions.error.errorSchema`      | `Object`  | JSON schema for the error response.                                                                                                                                                                 | Yes      |\n| `specGenerationOptions.error.errorStatusCode`  | `String`  | HTTP status code for the error response (e.g., `\"400\"`, `\"500\"`).                                                                                                                                   | Yes      |\n| `specGenerationOptions.error.errorDescription` | `String`  | Description for the error response schema.                                                                                                                                                          | No       |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgriffiths-waite%2Fxsd-to-openapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgriffiths-waite%2Fxsd-to-openapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgriffiths-waite%2Fxsd-to-openapi/lists"}