{"id":26256710,"url":"https://github.com/netcracker/qubership-apihub-api-visitor","last_synced_at":"2025-10-04T01:55:27.250Z","repository":{"id":270128559,"uuid":"907631701","full_name":"Netcracker/qubership-apihub-api-visitor","owner":"Netcracker","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-03T14:53:27.000Z","size":300,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-10-04T01:55:26.570Z","etag":null,"topics":["apihub","frontend","qubership-apihub"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Netcracker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-24T03:17:26.000Z","updated_at":"2025-10-03T14:53:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"8312b7cd-fb3a-4d24-8a96-324dd01dffba","html_url":"https://github.com/Netcracker/qubership-apihub-api-visitor","commit_stats":null,"previous_names":["netcracker/qubership-apihub-api-visitor"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/Netcracker/qubership-apihub-api-visitor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcracker%2Fqubership-apihub-api-visitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcracker%2Fqubership-apihub-api-visitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcracker%2Fqubership-apihub-api-visitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcracker%2Fqubership-apihub-api-visitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Netcracker","download_url":"https://codeload.github.com/Netcracker/qubership-apihub-api-visitor/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcracker%2Fqubership-apihub-api-visitor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278254462,"owners_count":25956599,"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","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["apihub","frontend","qubership-apihub"],"created_at":"2025-03-13T20:18:54.661Z","updated_at":"2025-10-04T01:55:27.213Z","avatar_url":"https://github.com/Netcracker.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Qubership APIHUB API Visitor\n\nThe APIHUB API Visitor is designed for secure and structured processing of Open API specifications using the `Visitor` pattern. It provides type-safe traversal of complex API schemes, including detecting self-references and preventing infinite recursion.\n\n## Features\n- **Type-safe traversal:** The module provides mechanisms for safe traversal and transformation of OpenAPI documents with full TypeScript support.\n- **Self loops processing:** Detects and marks self loops in schemas using the unique `valueAlreadyVisited` flag, preventing endless recursion.\n- **Visitor Pattern:** Uses the visitor pattern to bypass and transform API specification elements, making it easier to analyze API structure.\n- **Multiple distribution** formats: Supports CommonJS, ES modules, and integration with TypeScript projects, providing flexibility in use.\n\n## Self loops\nThe APIHUB API Visitor automatically identifies and marks self-references in schemas using a reliable mechanism for detecting and processing self-reference cycles during schema traversal. The mechanism is designed to prevent infinite recursion when traversing objects that may contain circular references (direct or indirect).\n\n## Usage\n```ts\nimport { OpenApiWalker } from '@netcracker/qubership-apihub-api-visitor'\nimport { denormalize, normalize } from '@netcracker/qubership-apihub-api-unifier'\nimport type { DenormalizeOptions, NormalizeOptions } from '@netcracker/qubership-apihub-api-unifier'\n\nconst walker = new OpenApiWalker();\n\nconst options: NormalizeOptions = {\n  resolveRef: true,\n  validate: true,\n  mergeAllOf: true,\n  unify: true,\n  liftCombiners: false,\n  allowNotValidSyntheticChanges: true,\n  originsAlreadyDefined: false,\n  /* Add additional options if necessary */\n}\nconst invertOptions: DenormalizeOptions = {\n  ...options,\n  originsAlreadyDefined: true,\n  /* Add additional options if necessary */\n}\n\n/* \n* Normalized OpenAPI document - a Dereferenced and Bundled version of OpenAPI spec, where all $ref references are resolved.\n* \n* 'normalize' - process resolves refs, merges allOf-s, sets default values according to specification, \n* unwrap system \"anyOf\" (type \"any\") and so on. Some of the stages are revertable, some not. \n* As a result we get completely \"normalized\" OpenAPI specification \n* which has transparent structure and can be easily matched with another normalized OpenAPI specification. \n* \n* 'denormalize - revertable things will be reverted (e.g. defaults, unified system anyOf-s), but resolved refs and merge allOf-s will be saved. \n* So it results to original specification with resolved refs and merged allOf-s.'\n*/\nconst normalizedOpenApiDocument = denormalize(normalize(operationData, options), invertOptions)\n\nwalker.walkPathsOnNormalizedSource(normalizedOpenApiDocument, {\n  // Handlers\n  responseStart: ({ responseCode }) =\u003e {\n    /* Do something */\n    return true\n  },\n  responseEnd: () =\u003e {\n    /* Do something */\n  },\n  mediaTypeStart: ({ mediaType }) =\u003e {\n    /* Do something */\n    return true\n  },\n  mediaTypeEnd: () =\u003e {\n    /* Do something */\n  },\n  // Add other handlers as needed\n\n}, { /* Options */ })\n```\n\n\n## Contributing\nPlease run the unit tests before submitting your PR: `npm test`. Hopefully your PR includes additional unit tests to illustrate your change/modification!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcracker%2Fqubership-apihub-api-visitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetcracker%2Fqubership-apihub-api-visitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcracker%2Fqubership-apihub-api-visitor/lists"}