Burgyn / MMLib.SwaggerForOcelot

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

Different gateway swagger response json than service swagger #203

Closed teomane closed 2 years ago

teomane commented 2 years ago

Hello,

I have an issue with the library. The example value of the response of a service is seen differently on the gateway swagger. Let me give an example:

This is the JSON of the response of my endpoint (taken from the service's swagger):

[
  {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "isRejected": true,
    "category": {
      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "parentCategoryId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "code": "string",
      "name": "string",
      "level": 0,
      "parentCategory": {
        "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "parentCategoryId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "code": "string",
        "name": "string",
        "level": 0
      }
    }
  }
]

And this is the JSON from the gateway for the same service:

[
  {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "isRejected": true,
    "category": {
      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "parentCategoryId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "code": "string",
      "name": "string",
      "level": 0
    }
  }
]

I can't see the node:

"parentCategory": {
        "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "parentCategoryId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "code": "string",
        "name": "string",
        "level": 0
}

What do you think about the problem ?

Burgyn commented 2 years ago

Hi,

it's from Ocelot Aggregates, or from standard service? If its from aggregation then looks similar like issue #191

teomane commented 2 years ago

It is not from aggregates. It is just a standard downstream service configured with Routes.

Burgyn commented 2 years ago

Can you please prepare simple reproducible example. Because it's OK on my projects.

eymentopcuoglu commented 2 years ago

Hi,

It seems rendering of circular-referenced objects on Swagger UI is still an ongoing issue. However, a comment on this issue seemed to work for me! For our case, to make the paths of the downstream Swagger endpoints relative, I used DownstreamSwaggerEndPointBasePath:

app.UseSwaggerForOcelotUI(opt =>
            {
                opt.DownstreamSwaggerEndPointBasePath = "../swagger/docs";
            });
teomane commented 2 years ago

Thank you @eymentopcuoglu. It works for me.