{"id":22489761,"url":"https://github.com/schwer/graphql-to-openapi","last_synced_at":"2026-01-18T11:59:22.646Z","repository":{"id":38390087,"uuid":"232937200","full_name":"schwer/graphql-to-openapi","owner":"schwer","description":"Convert a graphql query + graphql schema into an openapi spec.","archived":false,"fork":false,"pushed_at":"2024-04-13T18:00:03.000Z","size":7095,"stargazers_count":79,"open_issues_count":7,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-14T08:06:32.029Z","etag":null,"topics":["graphql","openapi"],"latest_commit_sha":null,"homepage":null,"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/schwer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-01-10T01:07:29.000Z","updated_at":"2024-04-16T21:55:31.531Z","dependencies_parsed_at":"2022-07-16T23:30:43.023Z","dependency_job_id":"385e49b9-ed3f-45d8-b798-781c01fe0822","html_url":"https://github.com/schwer/graphql-to-openapi","commit_stats":null,"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwer%2Fgraphql-to-openapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwer%2Fgraphql-to-openapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwer%2Fgraphql-to-openapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwer%2Fgraphql-to-openapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schwer","download_url":"https://codeload.github.com/schwer/graphql-to-openapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228500460,"owners_count":17930074,"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":["graphql","openapi"],"created_at":"2024-12-06T17:20:38.608Z","updated_at":"2026-01-18T11:59:22.617Z","avatar_url":"https://github.com/schwer.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# graphql-to-openapi\n\n[![NPM](https://img.shields.io/npm/v/graphql-to-openapi.svg)](https://npmjs.com/graphql-to-openapi)\n[![Known Vulnerabilities](https://snyk.io/test/github/schwer/graphql-to-openapi/badge.svg)](https://snyk.io/test/github/schwer/graphql-to-openapi)\n[![codecov](https://codecov.io/gh/schwer/graphql-to-openapi/branch/master/graph/badge.svg?token=XTRQ95F57X)](https://codecov.io/gh/schwer/graphql-to-openapi)\n\n\u003cimg alt=\"GraphQL → OpenAPI\" src=\"https://raw.github.com/schwer/graphql-to-openapi/master/docs/src/logo.svg?sanitize=true\"\u003e\n\nConvert a graphql query + graphql schema into an openapi spec.\n\n[Demo](https://schwer.github.io/graphql-to-openapi)\n\nNot to be confused with the obviously more useful\n[openapi-to-graphql](https://github.com/ibm/openapi-to-graphql).\n\n# Usage via CLI\n\n```\nnpx graphql-to-openapi --yaml --schema \u003cschemaFilename\u003e --query \u003cqueryFilename\u003e\n```\n\n\u003cimg alt=\"GraphQL → OpenAPI\" src=\"https://raw.github.com/schwer/graphql-to-openapi/master/static/usage.gif\"\u003e\n\n## Unknown Scalar Configuration via the CLI\n\nUnknown scalars are scalar types in the graphql schema that do not obviously map to an openapi type.\n\nThe default behavior for unknown scalars is to treat them as `string` types in the output openapi schema.\nIf you desire to override that behavior, supply a scalar config file to the graphq-to-openapi tool:\n\n```\nExample CLI usage:\n\nnpx graphql-to-openapi --scalarConfigFile myScalarConfig.json --yaml --schema \u003cschemaFilename\u003e --query \u003cqueryFilename\u003e\n\n---\n\nmyScalarConfig.json:\n{\n  \"DateTimeScalar\": {\n    \"type\": \"string\",\n    \"description\": \"YYYY-MM-DD date\",\n    \"example\": \"2017-01-01\",\n    \"format\": \"date\",\n    \"pattern\": \"YYYY-MM-DD\",\n    \"minLength\": 0,\n    \"maxLength\": 10\n  }\n}\n```\n\n# Usage as a module\n\n```typescript\nimport { graphqlToOpenApi } from 'graphql-to-openapi';\n\nconst { error, openApiSchema, queryErrors, schemaError } = graphqlToOpenApi({\n  schema,\n  query,\n});\n\n// error will contain any graphql-to-openapi errors if they exist.\n// graphql-to-openapi only throws an error if you've failed to name\n// the input query. The name of the input query is used to define the\n// openapi route name.\n\n// schemaError is an error in the parsing of the input schema.\n\n// queryErrors are errors associated with parsing and validating the input query.\n// This includes any validation issues when matching the query with the schema.\n\n// openApiSchema will contain the deserialized openapi schema for the\n// specified query.\n```\n\n## For Developers contributing to this project\n\n### To get started:\n\n1. Clone the github repo `git clone git@github.com/schwer/graphql-to-openapi`\n1. `npm install // install dependencies`\n1. `npm run test:watch`\n\n### Updating the documentation:\n\n1. The `docs` subdirectory contains a vite static web app.\n1. `cd docs \u0026\u0026 npm run start`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschwer%2Fgraphql-to-openapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschwer%2Fgraphql-to-openapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschwer%2Fgraphql-to-openapi/lists"}