{"id":30237939,"url":"https://github.com/stainless-api/merge-openapi-spec-action","last_synced_at":"2025-08-15T02:58:04.160Z","repository":{"id":299455207,"uuid":"1003072402","full_name":"stainless-api/merge-openapi-spec-action","owner":"stainless-api","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-17T11:29:53.000Z","size":528,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-10T00:36:56.032Z","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/stainless-api.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,"zenodo":null}},"created_at":"2025-06-16T15:21:40.000Z","updated_at":"2025-06-17T11:29:57.000Z","dependencies_parsed_at":"2025-06-16T17:41:06.781Z","dependency_job_id":"cb7b59d1-5dfb-4f5c-810e-a3e877bbecc0","html_url":"https://github.com/stainless-api/merge-openapi-spec-action","commit_stats":null,"previous_names":["stainless-api/merge-openapi-spec-action"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stainless-api/merge-openapi-spec-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stainless-api%2Fmerge-openapi-spec-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stainless-api%2Fmerge-openapi-spec-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stainless-api%2Fmerge-openapi-spec-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stainless-api%2Fmerge-openapi-spec-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stainless-api","download_url":"https://codeload.github.com/stainless-api/merge-openapi-spec-action/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stainless-api%2Fmerge-openapi-spec-action/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270515656,"owners_count":24598440,"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-08-15T02:00:12.559Z","response_time":110,"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":[],"created_at":"2025-08-15T02:57:58.830Z","updated_at":"2025-08-15T02:58:04.131Z","avatar_url":"https://github.com/stainless-api.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Merge OpenAPI Specs Action\n\nA GitHub Action to merge multiple OpenAPI specification files (JSON/YAML) into a single YAML file. Perfect for consolidating microservice APIs before uploading to [Stainless](https://stainless.com)!\n\n## Features\n\n- Supports both JSON and YAML OpenAPI specification files\n- Handles glob patterns and direct file paths\n- Merges using [Redocly CLI](https://redocly.com/docs/cli/) for proper OpenAPI spec handling\n- Preserves tags and tag groups from source specs\n- Verifies merge integrity by comparing path counts\n- Outputs the merged file path and total path count\n\n## Inputs\n\n| Input         | Description                                                                  | Required | Default                 |\n| ------------- | ---------------------------------------------------------------------------- | -------- | ----------------------- |\n| `input_files` | Glob patterns or file paths of OpenAPI spec files to merge (comma-separated) | Yes      | -                       |\n| `output_path` | Path where the merged file will be saved                                     | No       | `./merged-openapi.yaml` |\n\n## Outputs\n\n| Output        | Description                                       |\n| ------------- | ------------------------------------------------- |\n| `merged_file` | Path to the merged OpenAPI specification file     |\n| `path_count`  | Total number of paths in the merged specification |\n\n## How It Works\n\n1. **Discovery**: The action finds files matching your input patterns (supports glob patterns and direct file paths)\n2. **Merging**: Uses Redocly CLI's `join` command to properly merge OpenAPI specs while handling:\n   - Component references\n   - Tags and tag groups\n   - Conflicting paths (last one wins)\n3. **Conversion**: The final output is saved as a YAML file\n4. **Verification**: Path counts are compared before and after merging\n5. **Output**: The merged file path and total path count are available as action outputs\n\n## Usage\n\nIf you have multiple OpenAPI spec files in a directory structure like:\n\n```\napi-specs/\n├── users-api.json\n├── products-api.yaml\n├── orders-api.yml\n└── payments/\n    └── payments-api.json\n```\n\nThis action will merge them all into a single file:\n\n```yaml\n- name: Merge OpenAPI specs\n  uses: stainless-api/merge-openapi-specs-action@main\n  with:\n    input_files: 'api-specs/**/*.yaml,api-specs/**/*.json'\n    output_path: ./merged-api.yaml\n```\n\n### Integration with Stainless SDK Build Action\n\n```yaml\nname: Build SDK from Merged Specs\n\non:\n  push:\n    branches: [main]\n    paths:\n      - 'api-specs/**'\n\njobs:\n  merge-and-build-sdk:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n\n      - name: Merge all OpenAPI specs\n        id: merge\n        uses: stainless-api/merge-openapi-specs-action@main\n        with:\n          input_files: 'api-specs/**/*.yaml,api-specs/**/*.json'\n          output_path: ./complete-api.yaml\n\n      - name: Build SDKs\n        uses: stainless-api/build-sdk-action@main\n        with:\n          stainless_api_key: ${{ secrets.STAINLESS_API_KEY }}\n          org: my-org\n          project: my-project\n          oas_path: ${{ steps.merge.outputs.merged_file }}\n          config_path: ./stainless.yaml\n```\n\n### Complete SDK Pipeline Example\n\n```yaml\nname: Build and Publish SDKs\n\non:\n  push:\n    branches: [main]\n    paths:\n      - 'services/*/openapi.yaml'\n      - 'services/*/openapi.json'\n\njobs:\n  build-sdks:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n\n      # Step 1: Merge all microservice API specs\n      - name: Merge microservice APIs\n        id: merge-specs\n        uses: stainless-api/merge-openapi-specs-action@main\n        with:\n          input_files: 'services/*/openapi.yaml,services/*/openapi.json'\n          output_path: ./platform-api.yaml\n\n      # Step 2: Validate the merged spec\n      - name: Validate OpenAPI spec\n        run: |\n          npx @redocly/cli lint ${{ steps.merge-specs.outputs.merged_file }}\n\n      # Step 3: Build SDKs with Stainless\n      - name: Run merge build\n        uses: stainless-api/build-sdk-action/merge@main\n        with:\n          stainless_api_key: ${{ secrets.STAINLESS_API_KEY }}\n          org: ${{ env.STAINLESS_ORG }}\n          project: ${{ env.STAINLESS_PROJECT }}\n          oas_path: ${{ env.OAS_PATH }}\n          commit_message: ${{ env.COMMIT_MESSAGE }}\n```\n\n## License\n\nCopyright Stainless 2025\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstainless-api%2Fmerge-openapi-spec-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstainless-api%2Fmerge-openapi-spec-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstainless-api%2Fmerge-openapi-spec-action/lists"}