{"id":21262845,"url":"https://github.com/stackql/deno-openapi-dereferencer","last_synced_at":"2025-03-15T07:44:14.209Z","repository":{"id":262923883,"uuid":"888790673","full_name":"stackql/deno-openapi-dereferencer","owner":"stackql","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-15T21:04:10.000Z","size":86,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T22:43:08.217Z","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/stackql.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":"2024-11-15T02:28:07.000Z","updated_at":"2024-11-15T21:04:13.000Z","dependencies_parsed_at":"2024-11-15T03:27:24.809Z","dependency_job_id":"32a56614-9e88-4ddd-84c4-b92542000992","html_url":"https://github.com/stackql/deno-openapi-dereferencer","commit_stats":null,"previous_names":["stackql/deno-openapi-dereferencer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackql%2Fdeno-openapi-dereferencer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackql%2Fdeno-openapi-dereferencer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackql%2Fdeno-openapi-dereferencer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackql%2Fdeno-openapi-dereferencer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackql","download_url":"https://codeload.github.com/stackql/deno-openapi-dereferencer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243701314,"owners_count":20333616,"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-11-21T04:59:31.094Z","updated_at":"2025-03-15T07:44:14.163Z","avatar_url":"https://github.com/stackql.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @stackql/deno-openapi-dereferencer\r\n\r\nA Deno module to recursively dereference and flatten OpenAPI specifications. This module provides functions to handle `$ref`, `allOf`, `oneOf`, and `anyOf` structures, creating a fully dereferenced and optionally flattened document.  \r\n\r\nSee the project on [__jsr__](https://jsr.io/@stackql/deno-openapi-dereferencer) for more info.\r\n\r\n## Features\r\n\r\n- **Full dereferencing**: Resolves all `$ref` references within an OpenAPI specification.\r\n- **Flattening**: Merges `allOf` schemas into a single object.\r\n- **Selective processing**: Allows dereferencing from a specific path within the document.\r\n- **Path-based exclusion**: Optionally skip dereferencing for specific paths within the document using `ignorePaths`.\r\n\r\n## Usage\r\n\r\n### Importing the Module\r\n\r\nTo use the module, import it from Deno Land:\r\n\r\n```typescript\r\nimport { \r\n    dereferenceApi, \r\n    flattenAllOf, \r\n    selectFirstOfOneOf, \r\n    selectFirstOfAnyOf \r\n} from \"jsr:@stackql/deno-openapi-dereferencer\";\r\n```\r\n\r\n### Example Usage\r\n\r\n#### Fully Dereference an OpenAPI Document\r\n\r\n```typescript\r\nimport { dereferenceApi } from \"jsr:@stackql/deno-openapi-dereferencer\";\r\n\r\nconst apiDoc = await Deno.readTextFile(\"./path/to/openapi.yaml\");\r\nconst dereferencedDoc = await dereferenceApi(apiDoc);\r\nconsole.log(dereferencedDoc);\r\n```\r\n\r\n#### Flatten `allOf` Properties\r\n\r\n```typescript\r\nimport { flattenAllOf } from \"jsr:@stackql/deno-openapi-dereferencer\";\r\n\r\nconst flattenedDoc = await flattenAllOf(dereferencedDoc);\r\nconsole.log(flattenedDoc);\r\n```\r\n\r\n#### Selective Dereferencing with Ignore Paths\r\n\r\n```typescript\r\nimport { dereferenceApi } from \"jsr:@stackql/deno-openapi-dereferencer\";\r\n\r\nconst apiDoc = await Deno.readTextFile(\"./path/to/openapi.yaml\");\r\nconst ignorePaths = [\"$.components.x-stackQL-resources\"];  // Exclude specific paths\r\nconst dereferencedDoc = await dereferenceApi(apiDoc, \"$\", ignorePaths);\r\nconsole.log(dereferencedDoc);\r\n```\r\n\r\n### Functions\r\n\r\n- **`dereferenceApi(apiDoc: any, startAt: string = \"$\", ignorePaths?: string[]): Promise\u003cany\u003e`**  \r\n  Dereferences `$ref` properties from a specified path in the OpenAPI document. \r\n  - **Parameters:**\r\n    - `apiDoc`: The OpenAPI document object to be dereferenced.\r\n    - `startAt` (optional): JSONPath to specify the starting point for dereferencing. Defaults to the root (`\"$\"`).\r\n    - `ignorePaths` (optional): Array of JSONPath expressions. Any `$ref` found in these paths will be ignored.\r\n  - **Returns**: The fully dereferenced document.\r\n\r\n- **`flattenAllOf(apiDoc: any): Promise\u003cany\u003e`**  \r\n  Flattens `allOf` properties in an OpenAPI document, merging schemas into a single object.\r\n  - **Parameters:**\r\n    - `apiDoc`: The OpenAPI document object to be flattened.\r\n  - **Returns**: The document with `allOf` properties flattened.\r\n\r\n- **`selectFirstOfOneOf(apiDoc: any): Promise\u003cany\u003e`**  \r\n  Simplifies `oneOf` arrays by selecting the first schema.\r\n  - **Parameters:**\r\n    - `apiDoc`: The OpenAPI document object to process.\r\n  - **Returns**: The document with `oneOf` arrays simplified.\r\n\r\n- **`selectFirstOfAnyOf(apiDoc: any): Promise\u003cany\u003e`**  \r\n  Simplifies `anyOf` arrays by selecting the first schema.\r\n  - **Parameters:**\r\n    - `apiDoc`: The OpenAPI document object to process.\r\n  - **Returns**: The document with `anyOf` arrays simplified.\r\n\r\n## Testing\r\n\r\nRun tests using Deno’s testing suite:\r\n\r\n```bash\r\ndeno test --allow-read\r\n```\r\n\r\n## License\r\n\r\nMIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackql%2Fdeno-openapi-dereferencer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackql%2Fdeno-openapi-dereferencer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackql%2Fdeno-openapi-dereferencer/lists"}