Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 129 additions & 20 deletions dist/prepareCombine.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ If your API is split across multiple OpenAPI spec files, use the `prepare/combin

The action uses [Redocly CLI](https://redocly.com/docs/cli/) to combine specs, handling reference resolution and path merging. You can also configure how server URLs are handled when combining specs from different services.

When specs share `operationId` values, the action automatically prefixes conflicting IDs with a slug derived from each spec's `info.title` to avoid collisions during the combine. You can also set `prefix_with_info: true` to prefix tags and component names with each spec's title, which helps avoid collisions when multiple specs define tags or components with the same names.

### Converting Swagger 2.0 specs

If you have a Swagger 2.0 spec, use the `prepare/swagger` action to convert it to OpenAPI 3.x format. See [prepare_swagger.yml](./prepare_swagger.yml) for an example.
6 changes: 6 additions & 0 deletions examples/prepare_combine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ jobs:
# - https://users.api.example.com
# - https://billing.api.example.com

# Optional: Prefix tags and component names with each spec's info.title
# to avoid collisions across specs. Useful when multiple specs define
# tags or components with the same names.
#
# prefix_with_info: true

- name: Build SDKs
uses: stainless-api/upload-openapi-spec-action/build@v1
with:
Expand Down
7 changes: 7 additions & 0 deletions prepare/combine/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ inputs:
- <url2>
URLs not listed are ignored (removed, will use global server)
required: false
prefix_with_info:
description: >-
When true, prefixes tags and component names with the spec's info.title
to avoid collisions across specs. Uses Redocly's
--prefix-tags-with-info-prop and --prefix-components-with-info-prop flags.
required: false
default: "false"
log_level:
description: >-
Log verbosity level. Options: 'debug', 'info', 'warn', 'error', 'off'.
Expand Down
21 changes: 21 additions & 0 deletions src/__fixtures__/service-a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
openapi: "3.0.0"
info:
title: Service A
version: "1.0.0"
servers:
- url: https://api.example.com/service-a
paths:
/tenants:
get:
operationId: listTenants
summary: List tenants
responses:
"200":
description: Success
/tenants/{id}:
get:
operationId: getTenant
summary: Get tenant
responses:
"200":
description: Success
21 changes: 21 additions & 0 deletions src/__fixtures__/service-b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
openapi: "3.0.0"
info:
title: Service B
version: "1.0.0"
servers:
- url: https://api.example.com/service-b
paths:
/tenants:
get:
operationId: listTenants
summary: List tenants from B
responses:
"200":
description: Success
/health:
get:
operationId: healthCheck
summary: Health check
responses:
"200":
description: Success
Loading