Code Monkey home page Code Monkey logo

Comments (14)

Burgyn avatar Burgyn commented on June 2, 2024

Hi,
thanks for your report.

Please can you provide your ocelot.json configuration?

Thanks.

from mmlib.swaggerforocelot.

Kum4r4n avatar Kum4r4n commented on June 2, 2024

this is my

{
  "ReRoutes": [
    {
      "DownstreamPathTemplate": "/{everything}",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "industryapi",
          "Port": 80
        }
      ],
      "UpstreamPathTemplate": "/api/I/{everything}",
      "UpstreamHttpMethod": [ "POST", "PUT", "GET" ],
      

    },
    {
      "DownstreamPathTemplate": "/{everything}",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "logisticapi",
          "Port": 80
        }
      ],
      "UpstreamPathTemplate": "/api/L/{everything}",
      "UpstreamHttpMethod": [ "POST", "PUT", "GET" ],
      "SwaggerKey": "Logistic"
    },
    {
      "DownstreamPathTemplate": "/api/OrderAPI/{everything}",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "orderapi",
          "Port": 80
        }
      ],
      "UpstreamPathTemplate": "/api/O/{everything}",
      "UpstreamHttpMethod": [ "POST", "PUT", "GET" ]
    }
    //,

    //{
    //  "DownstreamPathTemplate": "/swagger/index.html",
    //  "DownstreamScheme": "http",
    //  "DownstreamHostAndPorts": [
    //    {
    //      "Host": "industryapi",
    //      "Port": 80
    //    }
    //  ],
    //  "UpstreamPathTemplate": "/api/IndustryAPI/swagger",
    //  "UpstreamHttpMethod": [ "POST", "PUT", "GET" ]
    //}

  ],

  "SwaggerEndPoints": [
    {
      "Key": "Industry",
      "Config": [
        {
          "Name": "Industry API",
          "Version": "v1",
          "Url": "http://localhost:51010/swagger/v1/swagger.json"

        }
      ]
    },

    {
      "Key": "Logistic",
      "Config": [
        {
          "Name": "Logistic API",
          "Version": "v1",
          "Url": "http://localhost:51020/swagger/v1/swagger.json"

        }
      ]
    }
  ],


  "GlobalConfiguration": {
    "RequestIdKey": "OcRequestId",
    "AdministrationPath": "/administration"
  }
}

from mmlib.swaggerforocelot.

Burgyn avatar Burgyn commented on June 2, 2024

Hi,
I apology, I cannot reproduce this behaviour.

  • Are you sure that swagger docs for Industry is accessible from http://localhost:51010/swagger/v1/swagger.json?
  • Added you services.AddSwaggerForOcelot(Configuration); in ConfigureServices method in Startup class?
  • Added you app.UseSwaggerForOcelotUI(Configuration); in Configure method in Startup class?

from mmlib.swaggerforocelot.

Kum4r4n avatar Kum4r4n commented on June 2, 2024

I used all of the thing what you say, but still i can't fix that
please help me on it !

from mmlib.swaggerforocelot.

Burgyn avatar Burgyn commented on June 2, 2024

please, you can provide a sample where this behavior is isolated

from mmlib.swaggerforocelot.

Kum4r4n avatar Kum4r4n commented on June 2, 2024

this is our project

we are using microservice with docker
and all of them separate projects with solution. normally swagger work with separately.
we had api gate way for all service.

i want to access all the service with one baseURL with api gate way in this case all of them are working good, the problem is swagger didn't work on api gate way i want to access all service swagger from api gate way.

from mmlib.swaggerforocelot.

Burgyn avatar Burgyn commented on June 2, 2024

I understand, this is main reason why this project was created. For microservices with one base api gateway base url. Where we want access to documentation for all downstream services in one place.


A typical problem when you get 500 Internal Server Error is that ApiGateway doesn't have access to SwaggerEndpoint.Url in your case http://localhost:51010/swagger/v1/swagger.json.

Are you sure your ApiGateway has access to this address? Can't be the problem in Docker configurations?

Doesn't it work when you use the following configuration?

"SwaggerEndPoints": [
    {
      "Key": "Industry",
      "Config": [
        {
          "Name": "Industry API",
          "Version": "v1",
          "Url": "http://industryapi:80/swagger/v1/swagger.json"
        }
      ]
    },
    {
      "Key": "Logistic",
      "Config": [
        {
          "Name": "Logistic API",
          "Version": "v1",
          "Url": "http://logisticapi:80/swagger/v1/swagger.json"
        }
      ]
    }
  ]

By the way, in the ReRout configurations for the industryapi you are missing SwaggerKey, but this does not cause this error.

from mmlib.swaggerforocelot.

Kum4r4n avatar Kum4r4n commented on June 2, 2024

http://localhost:51010/swagger/v1/swagger.json this one is working fine,

but its always shows same error.

this is my Docker Cofiguration file

services:

  apigw:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://+:80
    ports:
      - "51000:80"
    volumes:
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro

  industryapi:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://+:80
      - ConnectionString=${ESHOP_AZURE_INDUSTRY_DB:-Server=sqlserver ; Database=IndustryDb; User Id=sa;Password=password}
    ports:
      - "51010:80"
    volumes:
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro


  logisticapi:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://+:80
      - ConnectionString=${ESHOP_AZURE_INDUSTRY_DB:-Server=sqlserver ; Database=LogisticDb; User Id=sa;Password=password}
    ports:
      - "51020:80"
    volumes:
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro

image

from mmlib.swaggerforocelot.

Kum4r4n avatar Kum4r4n commented on June 2, 2024

This is my startup file

public void ConfigureServices(IServiceCollection services)
       {
           services.AddSwaggerForOcelot(Configuration);
           services.AddOcelot(Configuration);
       }

       // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
       public async void Configure(IApplicationBuilder app, IHostingEnvironment env)
       {
           app.UseSwaggerForOcelotUI(Configuration, opt =>
           {
               opt.EndPointBasePath = "/swagger/docs";
           });
           var pathBase = Configuration["PATH_BASE"];

           if (!string.IsNullOrEmpty(pathBase))
           {
               app.UsePathBase(pathBase);
           }

           await app.UseOcelot();
       }

from mmlib.swaggerforocelot.

Kum4r4n avatar Kum4r4n commented on June 2, 2024

I can provide my pc with teamviewer, can you allocate you time for me to solve this problem,
if you ok with it
i will waiting for you !

from mmlib.swaggerforocelot.

Burgyn avatar Burgyn commented on June 2, 2024

What do you have in PATH_BASE?

from mmlib.swaggerforocelot.

Kum4r4n avatar Kum4r4n commented on June 2, 2024

Now its working

but i got another issue,
api gate way downstream url missing the "/"

Like this
http://localhost:51000/api/I/industry - this is what i want !

this is what it got.
http://localhost:51000apiI/industry

image

from mmlib.swaggerforocelot.

Burgyn avatar Burgyn commented on June 2, 2024
  1. What have you changed when it works now?
  2. What do you have in PATH_BASE setting? (app.UsePathBase(pathBase);)

from mmlib.swaggerforocelot.

Kum4r4n avatar Kum4r4n commented on June 2, 2024

i didn't know about that,
two guys work on that , api gate way created by that guy, i am new for This field ,
i forgot to change the port number in swagger key

"Name": "Industry API",
          "Version": "v1",
          "Url": "http://industryapi:80/swagger/v1/swagger.json"

i here.

from mmlib.swaggerforocelot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.