Closed ThiyagarajanVellaichamy closed 4 years ago
Hi, I try to figure out where the problem is, but without success.
I don't know why he create the wrong address. localhost://5003
. You do not have a special value filled in baseUrl in downstream service swagger?
And one question? Need you really VirtualDirectory
? VirtualDirectory
is necessary only if you host your service as virtual app in IIS.
Hi, I try to figure out where the problem is, but without success.
I don't know why he create the wrong address.
localhost://5003
. You do not have a special value filled in baseUrl in downstream service swagger?And one question? Need you really
VirtualDirectory
?VirtualDirectory
is necessary only if you host your service as virtual app in IIS.
Thanks for the valuable Answer,
I have removed virtual directory too, but it gives same result.
Kindly help me out.
For further investigation, Can you provide your AuthorizationApi downstream swagger (original, before transforming by this library).
Thanks.
For further investigation, Can you provide your AuthorizationApi downstream swagger (original, before transforming by this library).
Thanks. services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Authentication Services", Version = "v1", Description = "Authentication service" }); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { In = ParameterLocation.Header, Description = "Please enter into field the word 'Bearer' following by space and JWT", Name = "Authorization", Type = SecuritySchemeType.ApiKey, Scheme = "Bearer" }); c.AddSecurityRequirement(new OpenApiSecurityRequirement() { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" }, Scheme = "oauth2", Name = "Bearer", In = ParameterLocation.Header }, new List
() } }); });
sorry but i meant swagger.json.
sorry but i meant swagger.json.
{ "openapi": "3.0.1", "info": { "title": "Authentication Services", "description": "Authentication service", "version": "v1" }, "servers": [ { "url": "/api" } ], "paths": { "/v{version}/Authentication": { "post": { "tags": [ "Authentication" ], "parameters": [ { "name": "version", "in": "path", "required": true, "schema": { "type": "string" } } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PostAuth" } }, "text/json": { "schema": { "$ref": "#/components/schemas/PostAuth" } }, "application/*+json": { "schema": { "$ref": "#/components/schemas/PostAuth" } } } }, "responses": { "200": { "description": "Success", "content": { "text/plain": { "schema": { "$ref": "#/components/schemas/LoginResponseResult" } }, "application/json": { "schema": { "$ref": "#/components/schemas/LoginResponseResult" } }, "text/json": { "schema": { "$ref": "#/components/schemas/LoginResponseResult" } } } } } }, "get": { "tags": [ "Authentication" ], "parameters": [ { "name": "version", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Success", "content": { "text/plain": { "schema": { "type": "string" } }, "application/json": { "schema": { "type": "string" } }, "text/json": { "schema": { "type": "string" } } } } } } } }, "components": { "schemas": { "PostAuth": { "required": [ "password", "userName" ], "type": "object", "properties": { "userName": { "type": "string" }, "password": { "type": "string" } }, "additionalProperties": false }, "LoginResponse": { "type": "object", "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string", "nullable": true }, "token": { "type": "string", "nullable": true }, "refreshToken": { "type": "string", "nullable": true } }, "additionalProperties": false }, "Status": { "enum": [ 0, 1, 2, 3 ], "type": "integer", "format": "int32" }, "LoginResponseResult": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/LoginResponse" }, "status": { "$ref": "#/components/schemas/Status" }, "message": { "type": "string", "nullable": true, "readOnly": true } }, "additionalProperties": false } }, "securitySchemes": { "Bearer": { "type": "apiKey", "description": "Please enter into field the word 'Bearer' following by space and JWT", "name": "Authorization", "in": "header" } } }, "security": [ { "Bearer": [ ] } ] }
Hi,
thanks for sharing your settings, they helped me understand the issue.
You have (I don't know why) in your swagger this setting:
"servers": [
{
"url": "/api"
}
]
If you really need this settings, than you can change it in ocelot config.
{
"Key": "authswagger",
"HostOverride": "",
"Config": [
{
"Name": "Authentication API",
"Version": "v1",
"Url": "http://localhost:5300/swagger.json"
}
]
}
The key is "HostOverride": "",
I hope I helped.
Hi,
thanks for sharing your settings, they helped me understand the issue.
Problem description
You have (I don't know why) in your swagger this setting:
"servers": [ { "url": "/api" } ]
Workaround
If you really need this settings, than you can change it in ocelot config.
{ "Key": "authswagger", "HostOverride": "", "Config": [ { "Name": "Authentication API", "Version": "v1", "Url": "http://localhost:5300/swagger.json" } ] }
The key is
"HostOverride": "",
I hope I helped.
Yes, You resolved the issue, thanks.
I am glad to hear that
everything has been rendered in view, when trying to execute API through Swagger, getting invalid schema. find the configuration and screen shot below, please help me out, if there I missed anything from my end.
ocelot.json: { "ReRoutes": [ { "DownstreamPathTemplate": "/api/{everything}", "DownstreamScheme": "https", "DownstreamHostAndPorts": [ { "Host": "localhost", "Port": 5001 } ], "UpstreamPathTemplate": "/auth-service/{everything}", "UpstreamHttpMethod": [ "Get", "Post" ], "SwaggerKey": "authswagger", "VirtualDirectory": "/authswagger" } ], "SwaggerEndPoints": [ { "Key": "gateway", "TransformByOcelotConfig": false, "Config": [ { "Name": "Gateway", "Version": "v1", "Url": "https://localhost:5003/swagger/v1/swagger.json" } ] }, { "Key": "authswagger", "Config": [ { "Name": "Authentication API", "Version": "v1", "Url": "https://localhost:5001/api/swagger/v1/swagger.json" } ] } ], "GlobalConfiguration": { "BaseUrl": "https://localhost" } }