@@ -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'
0 commit comments