Burgyn / MMLib.SwaggerForOcelot

This repo contains swagger extension for ocelot.
MIT License
351 stars 93 forks source link

[Question] SwaggerEndpoints configurations per enviroment #238

Closed maxoizs closed 1 year ago

maxoizs commented 1 year ago

I have a question regarding SwaggerEndpoints, I'm using ocelot and swagger for ocelot, with configuration folder and so far it works fine, the issue is, in SwaggerEndpoint how do I mention that base URL should change per environment, I've it fixed for dev environment now, but I would like to push to qa and stage as well. so ocelot.swaggerendpoints.json like that

{
  "SwaggerEndPoints": [
    {
      "Key": "ProductService",
      "Config": [
        {
          "Name": "Product Service",
          "Version": "v1",
          "Url": "https://service-dev.net/swagger/v1/swagger.json"
        }
      ]
    }
   ]
}

example I would like to be in QA environment like this https://service-qa.net/swagger/v1/swagger.json and stage https://service-stage.net/swagger/v1/swagger.json etc

do you guys add multi configs for all environments or do change that file on pipeline using yaml or do you override from code and how, or does the global configuration for ocelot work and how please ?

Burgyn commented 1 year ago

Hi @maxoizs,

for these purposes I use the Service discovery, especially AppConfiguration (different appsettings.json for different environments).

SwaggerForOcelot can read documentation from services defined in by that providers. See documentation.

maxoizs commented 1 year ago

@Burgyn thanks a lot , AppConfiguratoin as a service discovery worked very well so far, and appSettings is much easier to configure per environment especially that we were using docker, and replace a token within a docker image was a nightmare for me 😄 , thanks a lot for that.

Burgyn commented 1 year ago

I'm glad I could help