Feature: Merge this with your AddYarp
JohnGalt1717 opened this issue · 0 comments
Since this fundamentally is just using proxy, the best approach and super powerful one would be to take your AddYarp experiments, make it take all dependencies and map them automatically with pathing that automatically sets up the clusters, and for each do an AddOpenApi that takes the micro-services endpoints for the .json/.yaml file, and feeds that into a (defaulted to) /help endpoint for the swagger UI with all of the .json files configured automatically something like this, but with full injection:
window.onload = function () {
var full = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
const ui = SwaggerUIBundle({
urls: [
**{ url: "/assist/help/v1/openapi.json", name: "Assist" },
{ url: "/contacts/help/v1/openapi.json", name: "Contacts" },
{ url: "/events/help/v1/openapi.json", name: "Event Queue" },
{ url: "/documents/help/v1/openapi.json", name: "Documents" },
{ url: "/learning/help/v1/openapi.json", name: "Learning" },
{ url: "/messaging/help/v1/openapi.json", name: "Messaging" },
{ url: "/reports/help/v1/openapi.json", name: "Reports" },
{ url: "/research/help/v1/openapi.json", name: "Research" },
{ url: "/search/help/v1/openapi.json", name: "Search" },
{ url: "/security/help/v1/openapi.json", name: "Security" },**
],
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout",
oauth2RedirectUrl: full + "/oauth2-redirect.html"
});
ui.initOAuth({
clientId: "api",
appName: "Anhour Api",
scopeSeparator: " ",
scopes: ["openid", "profile", "phone", "address", "api", "email", "roles"],
usePkceWithAuthorizationCodeGrant: true,
useBasicAuthenticationWithAccessCodeGrant: true,
allowedGrantTypes: 'password'
});
window.ui = ui;
};
And have a flag if people only want it exposed in dev and not production.
This is the holly grail, and if this outputted to the manifest and Aspirate could then take that and create an K8s ingress with all of that? That would be epic.
Add in certificate aquisition for SSL proxying as a definition that was generated to the manifest that Aspirate could then deploy as cert-manager, (and Azure could integrate with Azure Keyvault certs) with automatic update of certs on renew, and wow, you'd be really solving all of the biggest problems getting this stuff setup properly in k8s and other similar environments all in one go.
Given that I've cobbled together something sort of like this from your code snippets, if you would create a unified for purpose repo, I'd be happy to contribute where I can to make this a reality.