{"id":16860476,"url":"https://github.com/webpro/parse-openapi","last_synced_at":"2025-04-11T08:33:52.899Z","repository":{"id":66134209,"uuid":"476396257","full_name":"webpro/parse-openapi","owner":"webpro","description":"OpenAPI v3 parser","archived":false,"fork":false,"pushed_at":"2022-03-31T17:31:04.000Z","size":29,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T06:05:09.716Z","etag":null,"topics":["openapi","openapi3","parser","typescript"],"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/webpro.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-03-31T16:48:53.000Z","updated_at":"2023-02-11T12:24:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"d0e08f0d-5e6f-4b16-953c-5b8fabb212f2","html_url":"https://github.com/webpro/parse-openapi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fparse-openapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fparse-openapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fparse-openapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fparse-openapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpro","download_url":"https://codeload.github.com/webpro/parse-openapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248361679,"owners_count":21090963,"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":["openapi","openapi3","parser","typescript"],"created_at":"2024-10-13T14:24:26.829Z","updated_at":"2025-04-11T08:33:52.890Z","avatar_url":"https://github.com/webpro.png","language":"TypeScript","readme":"# parse-openapi\n\nThe OpenAPi v3 parser extracted from\n[openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen).\nSo first of all, all credits go to\n[Ferdi Koomen](https://github.com/ferdikoomen) for his work on this great\nlibrary. Only the parser is needed to render the models, services and hooks with\ncustom templates, hence this stripped down version.\n\n## Installation\n\n    npm install -D parse-openapi openapi-types\n\n## API\n\n```typescript\nimport { readFile, writeFile } from 'fs/promises';\nimport { parse } from 'parse-openapi';\nimport { renderModel, renderService } from './templates';\nimport type { OpenAPIV3 } from 'openapi-types';\n\nconst specs: OpenAPIV3 = JSON.parse(await readFile('swagger.json', 'utf8'));\n\nconst { version, server, models, services } = parse(specs);\n\nmodels.forEach(model =\u003e writeFile(`${model.name}.ts`, renderModel(model)));\nservices.forEach(service =\u003e\n  writeFile(`${service.name}.ts`, renderService(service))\n);\n```\n\n## Example render function\n\nThis could be anything from Handlebars templates to template literals. Here's a\nminimal example:\n\n```typescript\nimport type { Operation, Service } from 'parse-openapi';\n\nconst renderOperation = (operation: Operation): string =\u003e {\n  const [result] = operation.results;\n  return `\n/**\n * ${operation.summary}\n * ${operation.description}\n * @returns ${result.type} ${result.description}\n ${operation.deprecated ? '* @deprecated' : ''}\n */\nexport function ${operation.name}([...]): Promise\u003c${result.type}\u003e {\n  return request({\n    method: '${operation.method}',\n    path: \\`${operation.path}\\`,\n    [...]\n  });\n}`;\n};\n\nexport default (service: Service) =\u003e {\n  return services.operations.map(renderOperation).join(';');\n};\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpro%2Fparse-openapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpro%2Fparse-openapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpro%2Fparse-openapi/lists"}