Skip to content

Support OpenAPI-First, Forked Collection Workflow #8940

@therockstorm

Description

@therockstorm

We use a Postman Team account to publish Collections and Documentation and drive everything off of the OpenAPI spec during CI in an automated fashion. An ideal workflow would be,

  1. Update OpenAPI spec
  2. Upload to Postman via Update Schema, triggering the Collection created from that schema and the Documentation created from that Collection to automatically update
  3. Customers of our API can fork the Collection so they can optionally pull in updates as they're made

Here's another explanation of what we're after.

Unfortunately, reality is quite different. Here is our current workflow to get this working,

  1. Update OpenAPI spec
    1. The spec must explicitly include the Authorization and Content-Type headers in each endpoint in order to show correctly in Postman Documentation's code samples (link to issue) as described in this issue comment. We're also impacted by Auth issues described here, here, and here.
  2. Resolve the schema to a single file using openapi-generator-cli's openapi-yaml generator because the tool in the next step returns schema type not provided errors for multi-file specs referenced via $ref
  3. Use a forked version of Postman's openapi-to-postmanv2 tool to convert the spec to a Postman collection. The forked version contains the following fixes
    1. This PR ensures IDs for the same endpoints remain unchanged. This is crucial because otherwise when you update the collection, it removes all the old endpoints and creates all new ones. This, in turn, changes the URLs for each endpoint if you're using Postman's Documentation. Here's another issue from 2017 describing the problem.
    2. This PR so you can pass configuration via the CLI
    3. Increased stackLimit from 10 to 20 since it's not configurable and sets some request bodies to <Error: Too many levels of nesting to fake this schema> otherwise
  4. Because of 1. i. above, we next have to run a sed command to remove the Content-Type header automatically added by the openapi-to-postman tool so only the manually added one remains, otherwise it shows up twice in the Collection and Documentation. I'm not sure why this automatically included header doesn't show up in code samples but the manually added one does.
  5. Convert the schema to JSON because Postman's Update Schema API requires it as a string and it's not trivial to escape YAML as a string inside a JSON value
  6. Upload to Postman via Update Schema, this does nothing to Collections created from the schema, so...
    1. Could be solved with this issue
  7. Upload openapi-to-postman output via Update Collection, triggering the Documentation created from that Collection to automatically update.
  8. Our customers must either continue using their old collections or import the new one and lose all their changes since forking/version control is only available within teams.

Related issues

Is there a simpler, already existing workflow to accomplish what we're after? This seems like a relatively normal use-case: update one file (the OpenAPI spec) and have all downstream artifacts ("Golden" Collection, Documentation, Forked Collections, SDKs) automatically pull in those changes.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions