Skip to content

Commit 4678afb

Browse files
authored
Merge pull request #325 from signalwire/Devon/postman-collection-structure
publish-postman: wrap tags under APIs folder, alphabetize, fix V2 example option
2 parents 8c199fe + f90f987 commit 4678afb

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

.github/workflows/publish-postman.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,36 @@ jobs:
120120
-p \
121121
-c scripts/postman/convert-options.json
122122
123-
- name: Strip generated IDs and wrap for PUT
123+
- name: Group APIs under a wrapper folder, strip IDs, wrap for PUT
124124
if: steps.changed.outputs.changed == 'true'
125125
# Postman API requires {"collection": {...}} and rejects payloads
126126
# carrying foreign _postman_id / id / uid fields.
127+
#
128+
# Layout produced by openapi-to-postmanv2 with `folderStrategy: "Tags"`
129+
# and `includeWebhooks: true`: top-level `.item[]` is a flat list of
130+
# tag-derived folders plus one converter-generated "Webhooks" folder
131+
# that holds the OpenAPI 3.1 `webhooks:` entries. We restructure so
132+
# webhooks stay peer-level at the root while every tag folder moves
133+
# into a single wrapper folder named "APIs", alphabetized
134+
# case-insensitively. "cXML *" then slots near "Call Flows" instead
135+
# of at the bottom under ASCII byte order.
136+
#
137+
# Partitioning is by name ("Webhooks" vs the rest) because the
138+
# converter doesn't tag the synthetic webhooks folder with any
139+
# distinguishing metadata. If a future spec adds a tag literally
140+
# named "Webhooks", that tag would land at the root with the
141+
# webhooks folder instead of inside "APIs" — revisit then.
142+
# openapi-to-postmanv2 has no built-in sort or wrap option, so we
143+
# do it here. Items inside each tag folder keep their existing
144+
# path/method order; items inside the Webhooks folder are unchanged.
127145
run: |
128-
jq 'walk(if type == "object" then del(._postman_id, .id, .uid) else . end) | {collection: .}' \
129-
collection.json > payload.json
146+
jq '
147+
(.item | map(select(.name != "Webhooks")) | sort_by(.name | ascii_downcase)) as $apis
148+
| (.item | map(select(.name == "Webhooks"))) as $webhooks
149+
| .item = ([{name: "APIs", item: $apis}] + $webhooks)
150+
| walk(if type == "object" then del(._postman_id, .id, .uid) else . end)
151+
| {collection: .}
152+
' collection.json > payload.json
130153
131154
- name: PUT collection to Postman
132155
if: steps.changed.outputs.changed == 'true'
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"folderStrategy": "Tags",
3-
"requestParametersResolution": "Example",
4-
"exampleParametersResolution": "Example",
3+
"parametersResolution": "Example",
54
"alwaysInheritAuthentication": true,
65
"includeWebhooks": true
76
}

0 commit comments

Comments
 (0)