{"id":15440840,"url":"https://github.com/jonluca/har-to-openapi","last_synced_at":"2025-08-22T06:32:38.664Z","repository":{"id":50702857,"uuid":"519317344","full_name":"jonluca/har-to-openapi","owner":"jonluca","description":"HAR to OpenAPI spec generator","archived":false,"fork":false,"pushed_at":"2023-08-11T17:51:31.000Z","size":5241,"stargazers_count":65,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-14T05:39:48.712Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonluca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-07-29T18:43:20.000Z","updated_at":"2024-04-12T21:31:47.000Z","dependencies_parsed_at":"2024-10-01T19:15:37.027Z","dependency_job_id":"2ad83251-b57b-476e-adb3-5acff5f1a4fd","html_url":"https://github.com/jonluca/har-to-openapi","commit_stats":{"total_commits":68,"total_committers":2,"mean_commits":34.0,"dds":"0.044117647058823484","last_synced_commit":"a32d1f688d41513c94299c7e2160152d7c3133fc"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonluca%2Fhar-to-openapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonluca%2Fhar-to-openapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonluca%2Fhar-to-openapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonluca%2Fhar-to-openapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonluca","download_url":"https://codeload.github.com/jonluca/har-to-openapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229934335,"owners_count":18147037,"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":[],"created_at":"2024-10-01T19:15:32.757Z","updated_at":"2024-12-20T10:08:23.826Z","avatar_url":"https://github.com/jonluca.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# HAR to OpenAPI\n\n[![npm Version](https://img.shields.io/npm/v/har-to-openapi.svg)](https://www.npmjs.com/package/har-to-openapi) [![License](https://img.shields.io/npm/l/har-to-openapi.svg)](https://www.npmjs.com/package/har-to-openapi)\n\nConvert a HAR file to an OpenAPI spec\n\n# Introduction\n\n_This library is loosely based on [har2openapi](https://github.com/dcarr178/har2openapi), but cleaned up and changed for usage in a more programmatic fashion_\n\n# Getting Started\n\n```\nyarn add har-to-openapi\n```\n\nor\n\n```\nnpm i --save har-to-openapi\n```\n\n# Usage\n\n```typescript\nimport { generateSpec } from \"har-to-openapi\";\n\n// read a har file from wherever you want - in this example its just a root json object\n// const har = await fs.readFile(\"my.har\");\n\nconst har = {\n  log: {\n    entries: [\n      {\n        index: 0,\n        request: {\n          method: \"CUSTOM\",\n          url: \"http://test.loadimpact.com/login\",\n          headers: [\n            {\n              name: \"Content-Type\",\n              value: \"application/x-www-form-urlencoded\",\n            },\n          ],\n          postData: {\n            mimeType: \"application/x-www-form-urlencoded\",\n            text: \"foo0=bar0\u0026foo1=bar1\",\n            params: [\n              {\n                name: \"foo0\",\n                value: \"bar0\",\n              },\n            ],\n          },\n        },\n      },\n    ],\n  },\n};\n\nconst openapi = await generateSpec(har, { relaxedMethods: true });\nconst { spec, yamlSpec } = openapi;\n// spec = { ... } openapi spec schema document\n// yamlSpec = string, \"info: ...\"\n```\n\n## Options\n\n```typescript\nexport interface Config {\n  // if true, we'll treat every url as having the same domain, regardless of what its actual domain is\n  // the first domain we see is the domain we'll use\n  forceAllRequestsInSameSpec?: boolean;\n  // if true, every path object will have its own servers entry, defining its base path. This is useful when\n  // forceAllRequestsInSameSpec is set\n  addServersToPaths?: boolean;\n  // try and guess common auth headers\n  guessAuthenticationHeaders?: boolean;\n  // if the response has this status code, ignore the body\n  ignoreBodiesForStatusCodes?: number[];\n  // whether non standard methods should be allowed (like HTTP MY_CUSTOM_METHOD)\n  relaxedMethods?: boolean;\n  // whether we should try and parse non application/json responses as json - defaults to true\n  relaxedContentTypeJsonParse?: boolean;\n  // a list of tags that match passed on the path, either [match_and_tag] or [match, tag]\n  tags?: ([string] | [string, string] | string)[] | ((url: string) =\u003e string | string[] | void);\n  // response mime types to filter for\n  mimeTypes?: string[];\n  // known security headers for this har, to add to security field in openapi (e.g. \"X-Auth-Token\")\n  securityHeaders?: string[];\n  // Whether to filter out all standard headers from the parameter list in openapi\n  filterStandardHeaders?: boolean;\n  // Whether to log errors to console\n  logErrors?: boolean;\n  // a string, regex, or callback to filter urls for inclusion\n  urlFilter?: string | RegExp | ((url: string) =\u003e boolean | Promise\u003cboolean\u003e);\n  // when we encounter a URL, try and parameterize it, such that something like\n  // GET /uuids/123e4567-e89b-12d3-a456-426655440000 becomes GET /uuids/{uuid}\n  attemptToParameterizeUrl?: boolean;\n  // when we encounter a path without a response or with a response that does not have 2xx, dont include it\n  dropPathsWithoutSuccessfulResponse?: boolean;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonluca%2Fhar-to-openapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonluca%2Fhar-to-openapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonluca%2Fhar-to-openapi/lists"}