Pitfalls when publishing an API referencing Domains that are unpublished
Hi,
I have stumbled onto a problem when publishing APIs. I have started using the Domains to store common types and components shared among APIs. The Domains are not yet published. When I publish my API my impression was that the API was stable - this is not the case, as components referred to in Domains that are not published yet, can change!
I am surprised that Swaggerhub does not check for references to unpublished Domains before publishing an API!
How should this be mananged? How does other people manage this?
the webhook listener should not be deployed on the SwaggerHub VM. I would suggest a small Linux instance on the same sub-net.
there I would run a small node.js listener that accepts the POST from SwaggerHub and parses the json copy of the spec that is included in the POST payload.
the parsing would look for $refs that contain the “…/domain/…” url inductive of a domain reference. Parse out the domain location (organization), name and version contained the the url, then use either the swaggerhub cli or the SwaggerHub Registry Api to publish that domain/version. Repeat until the spec is completely parsed.
the node.js code to do this should be fairly simple, you’ll just need to be able to find the $refs that are remote anchors, then pick out the 3 sub-strings that describe the domain.